[Codeforces Round #165 (Div. 2)]C. Magical Boxes

地址:http://codeforces.com/contest/270/problem/C

边读边算,算出当前所需最小箱子,每次结果进行对比,找最大

 1 #include <iostream>
 2 using namespace std;
 3 
 4 int n,k,a;
 5 
 6 int main()
 7 {
 8     ios::sync_with_stdio(false);
 9     cin>>n;
10     int ans=0;
11     for(int i=0;i<n;i++)
12     {
13         cin>>k>>a;
14         if(1==a) k++;
15         while(a!=1)
16         {
17             if(a%4!=0) a=a/4+1;
18             else a/=4;
19             k++;
20         }
21         ans=k>ans?k:ans;
22     }
23     cout<<ans<<endl;
24     return 0;
25 }

 

posted @ 2013-02-02 21:44  tjsuhst  阅读(186)  评论(0编辑  收藏  举报