codeforces-scrape

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

463A.md (1863B)


      1 Source: https://codeforces.com/problemset/problem/463/A
      2 
      3 A. Caisa and Sugar
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 Caisa is going to have a party and he needs to buy the ingredients for a big chocolate cake. For that he is going to the biggest supermarket in town.
     22 
     23 Unfortunately, he has just *s* dollars for sugar. But that's not a reason to be sad, because there are *n* types of sugar in the supermarket, maybe he able to buy one. But that's not all. The supermarket has very unusual exchange politics: instead of cents the sellers give sweets to a buyer as a change. Of course, the number of given sweets always doesn't exceed 99, because each seller maximizes the number of dollars in the change (100 cents can be replaced with a dollar).
     24 
     25 Caisa wants to buy only one type of sugar, also he wants to maximize the number of sweets in the change. What is the maximum number of sweets he can get? Note, that Caisa doesn't want to minimize the cost of the sugar, he only wants to get maximum number of sweets as change.
     26 
     27 Input
     28 
     29 The first line contains two space-separated integers *n*, *s* (1 ≤ *n*, *s* ≤ 100).
     30 
     31 The *i*-th of the next *n* lines contains two integers *x**i*, *y**i* (1 ≤ *x**i* ≤ 100; 0 ≤ *y**i* < 100), where *x**i* represents the number of dollars and *y**i* the number of cents needed in order to buy the *i*-th type of sugar.
     32 
     33 Output
     34 
     35 Print a single integer representing the maximum number of sweets he can buy, or -1 if he can't buy any type of sugar.
     36 
     37 Examples
     38 
     39 Input
     40 
     41 ```
     42 5 10  
     43 3 90  
     44 12 0  
     45 9 70  
     46 5 50  
     47 7 0
     48 ```
     49 
     50 Output
     51 
     52 ```
     53 50
     54 ```
     55 
     56 Input
     57 
     58 ```
     59 5 5  
     60 10 10  
     61 20 20  
     62 30 30  
     63 40 40  
     64 50 50
     65 ```
     66 
     67 Output
     68 
     69 ```
     70 -1
     71 ```
     72 
     73 Note
     74 
     75 In the first test sample Caisa can buy the fourth type of sugar, in such a case he will take 50 sweets as a change.