Topic: http: //codeforces.com/contest/270/problem/C
Ideas: Each box is an independent, four small box for a big box, the last remaining one box can hold all variable-length is 2 ^ k box to find the maximum side length of the box for all k.
#include <iostream> #include <cmath> using namespace std; int arr[100005]; int main() { int n; cin>>n; int k,a; int ans=0; int maxk=0; for (int i = 0; i < n; i++) { cin>>k>>a; if(k<maxk) continue; else maxk=k; while(1) { a=ceil(a/4.0); k++; if(a<=1) break; } ans=max(ans,k); } cout<<ans; return 0; }
Reproduced in: https: //www.cnblogs.com/danielqiu/archive/2013/02/02/2890271.html