Codeforces round #264 (Div. 2)

Source: Internet
Author: User

Question:

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.

Unfortunately, he has justSDollars for sugar. But that's not a reason to be sad, because there areNTypes 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 ).

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.

Input

The first line contains two space-separated IntegersN,?S(1? ≤?N,?S? ≤? 100 ).

TheI-Th of the nextNLines contains two integersXI,YI(1? ≤?XI? ≤? 100; 0? ≤?YI? <? 100), whereXIRepresents the number of dollars andYIThe number of cents needed in order to buyI-Th type of sugar.

Output

Print a single integer representing the maximum number of Sweets he can buy, or-1 if he can't buy any type of sugar.

Sample test (s) Input
5 103 9012 09 705 507 0
Output
50
Input
5 510 1020 2030 3040 4050 50
Output
-1
Note

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.


Analysis of the meaning of the question: in a simple simulation, pay attention to the special sentence when x = S & Y = 0.



Code:

#include <iostream>using namespace std;int main() {int i,n,s,x,y,d=-1;cin>>n>>s;for (i=0; i<n; i++) {cin>>x>>y;if (x==s && y==0)d=max(d,0);if (x<s) {d=max(d,(100-y)%100);}}cout<<d<<endl;}


Codeforces round #264 (Div. 2)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.