CF750C.New Year and Rating

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 19001900 or higher. Those with rating 18991899 or lower belong to the second division. In every contest, according to one's performance, his or her rating changes by some value, possibly negative or zero.

Limak competed in nn contests in the year 2016. He remembers that in the ii -th contest he competed in the division did_{i} (i.e. he belonged to this division just before the start of this contest) and his rating changed by cic_{i} just after the contest. Note that negative cic_{i} denotes the loss of rating.

What is the maximum possible rating Limak can have right now, after all nn contests? If his rating may be arbitrarily big, print "Infinity". If there is no scenario matching the given information, print "Impossible".

输入格式

The first line of the input contains a single integer nn ( 1<=n<=2000001<=n<=200000 ).

The ii -th of next nn lines contains two integers cic_{i} and did_{i} ( 100<=ci<=100-100<=c_{i}<=100 , 1<=di<=21<=d_{i}<=2 ), describing Limak's rating change after the ii -th contest and his division during the ii -th contest contest.

输出格式

If Limak's current rating can be arbitrarily big, print "Infinity" (without quotes). If the situation is impossible, print "Impossible" (without quotes). Otherwise print one integer, denoting the maximum possible value of Limak's current rating, i.e. rating after the nn contests.

输入输出样例

  • 输入#1

    3
    -7 1
    5 2
    8 2
    

    输出#1

    1907
    
  • 输入#2

    2
    57 1
    22 2
    

    输出#2

    Impossible
    
  • 输入#3

    1
    -5 1
    

    输出#3

    Infinity
    
  • 输入#4

    4
    27 2
    13 1
    -50 1
    8 2
    

    输出#4

    1897
    

说明/提示

In the first sample, the following scenario matches all information Limak remembers and has maximum possible final rating:

  • Limak has rating 19011901 and belongs to the division 11 in the first contest. His rating decreases by 77 .
  • With rating 18941894 Limak is in the division 22 . His rating increases by 55 .
  • Limak has rating 18991899 and is still in the division 22 . In the last contest of the year he gets +8+8 and ends the year with rating 19071907 .

In the second sample, it's impossible that Limak is in the division 11 , his rating increases by 5757 and after that Limak is in the division 22 in the second contest.

首页