CF269A.Magical Boxes

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Emuskald is a well-known illusionist. One of his trademark tricks involves a set of magical boxes. The essence of the trick is in packing the boxes inside other boxes.

From the top view each magical box looks like a square with side length equal to 2k2^{k} ( kk is an integer, k>=0k>=0 ) units. A magical box vv can be put inside a magical box uu , if side length of vv is strictly less than the side length of uu . In particular, Emuskald can put 4 boxes of side length 2k12^{k-1} into one box of side length 2k2^{k} , or as in the following figure:

Emuskald is about to go on tour performing around the world, and needs to pack his magical boxes for the trip. He has decided that the best way to pack them would be inside another magical box, but magical boxes are quite expensive to make. Help him find the smallest magical box that can fit all his boxes.

输入格式

The first line of input contains an integer nn ( 1<=n<=1051<=n<=10^{5} ), the number of different sizes of boxes Emuskald has. Each of following nn lines contains two integers kik_{i} and aia_{i} ( 0<=ki<=1090<=k_{i}<=10^{9} , 1<=ai<=1091<=a_{i}<=10^{9} ), which means that Emuskald has aia_{i} boxes with side length 2ki2^{k_{i}} . It is guaranteed that all of kik_{i} are distinct.

输出格式

Output a single integer pp , such that the smallest magical box that can contain all of Emuskald’s boxes has side length 2p2^{p} .

输入输出样例

  • 输入#1

    2
    0 3
    1 5
    

    输出#1

    3
    
  • 输入#2

    1
    0 4
    

    输出#2

    1
    
  • 输入#3

    2
    1 10
    2 2
    

    输出#3

    3
    

说明/提示

Picture explanation. If we have 3 boxes with side length 2 and 5 boxes with side length 1, then we can put all these boxes inside a box with side length 4, for example, as shown in the picture.

In the second test case, we can put all four small boxes into a box with side length 2.

首页