1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| #include <bits/stdc++.h> #define ios ios::sync_with_stdio(0),cin.tie(0) using namespace std; int n,m,tree[3000]; bool used[3000];
int main(){ ios; string s; memset(used,0,sizeof(used)); memset(tree,0,sizeof(tree)); getline(cin,s); stringstream ss(s); int ans = 0,temp; while(ss>>temp){ int cur = 1,height = 1; while(used[cur]){ if(temp<tree[cur])cur = cur*2; else cur = cur*2+1; height++; } tree[cur] = temp; used[cur] = 1; ans = max(ans,height); } cout<<ans<<endl; }
|