codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

750C.md (2598B)


      1 Source: https://codeforces.com/problemset/problem/750/C
      2 
      3 C. New Year and Rating
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 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.
     22 
     23 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.
     24 
     25 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".
     26 
     27 Input
     28 
     29 The first line of the input contains a single integer *n* (1 ≤ *n* ≤ 200 000).
     30 
     31 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.
     32 
     33 Output
     34 
     35 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.
     36 
     37 Examples
     38 
     39 Input
     40 
     41 ```
     42 3  
     43 -7 1  
     44 5 2  
     45 8 2
     46 ```
     47 
     48 Output
     49 
     50 ```
     51 1907
     52 ```
     53 
     54 Input
     55 
     56 ```
     57 2  
     58 57 1  
     59 22 2
     60 ```
     61 
     62 Output
     63 
     64 ```
     65 Impossible
     66 ```
     67 
     68 Input
     69 
     70 ```
     71 1  
     72 -5 1
     73 ```
     74 
     75 Output
     76 
     77 ```
     78 Infinity
     79 ```
     80 
     81 Input
     82 
     83 ```
     84 4  
     85 27 2  
     86 13 1  
     87 -50 1  
     88 8 2
     89 ```
     90 
     91 Output
     92 
     93 ```
     94 1897
     95 ```
     96 
     97 Note
     98 
     99 In the first sample, the following scenario matches all information Limak remembers and has maximum possible final rating:
    100 
    101 * Limak has rating 1901 and belongs to the division 1 in the first contest. His rating decreases by 7.
    102 * With rating 1894 Limak is in the division 2. His rating increases by 5.
    103 * 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.
    104 
    105 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.