CF750C.New Year and Rating
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
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 1900 or higher. Those with rating 1899 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 n contests in the year 2016. He remembers that in the i-th contest he competed in the division d__i (i.e. he belonged to this division just before the start of this contest) and his rating changed by c__i just after the contest. Note that negative c__i denotes the loss of rating.
What is the maximum possible rating Limak can have right now, after all n contests? If his rating may be arbitrarily big, print "Infinity". If there is no scenario matching the given information, print "Impossible".
每位 Codeforces 用户都有一个用一个整数表示的评分(rating),该整数可能为负数或零。用户被分为两个组别(division):第一组适用于评分为 1900 及以上的用户;评分为 1899 及以下的用户属于第二组。在每场比赛中,用户会根据其表现获得一定的评分变化值(可能为负数或零)。
Limak 在 2016 年参加了 n 场比赛。他记得在第 i 场比赛中,他所处的组别为 di(即,在该场比赛开始前他属于该组别),且该场比赛结束后他的评分变化了 ci。注意:负的 ci 表示评分下降。
在全部 n 场比赛结束后,Limak 当前可能拥有的最高评分为多少?如果他的评分可以任意大,请输出 "Infinity";如果不存在任何满足给定信息的情形,请输出 "Impossible"。
输入格式
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000).
The i-th of next n lines contains two integers c__i and d__i ( - 100 ≤ c__i ≤ 100, 1 ≤ d__i ≤ 2), describing Limak's rating change after the i-th contest and his division during the i-th contest contest.
输入的第一行包含一个整数 n(1≤n≤200000)。
接下来的 n 行中,第 i 行包含两个整数 ci 和 di(−100≤ci≤100,1≤di≤2),分别表示 Limak 在第 i 场比赛后的评分变化量,以及他在第 i 场比赛期间所在的组别。
输出格式
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 n contests.
如果利马克当前的评分可以任意大,则输出 “Infinity”(不带引号)。如果该情况不可能发生,则输出 “Impossible”(不带引号)。否则,输出一个整数,表示利马克当前评分(即经过 n 场比赛后的评分)的最大可能值。
输入输出样例
输入#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 1901 and belongs to the division 1 in the first contest. His rating decreases by 7.
- With rating 1894 Limak is in the division 2. His rating increases by 5.
- Limak has rating 1899 and is still in the division 2. In the last contest of the year he gets + 8 and ends the year with rating 1907.
In the second sample, it's impossible that Limak is in the division 1, his rating increases by 57 and after that Limak is in the division 2 in the second contest.
在第一个样例中,以下情形符合 Limak 所记得的所有信息,且最终评级达到可能的最大值:
- Limak 在第一场比赛时评分为 1901,属于第 1 分组。他的评分减少了 7。
- 评分为 1894 的 Limak 属于第 2 分组。他的评分增加了 5。
- Limak 的评分为 1899,仍属于第 2 分组。在当年的最后一场比赛中,他获得了 +8,最终以评分为 1907 结束这一年。
在第二个样例中,不可能出现如下情况:Limak 在第一场比赛中属于第 1 分组,评分增加了 57,而在第二场比赛中却属于第 2 分组。
输入解题思路,AI测评打分。不知道怎么写?