Codeforces A #264. Caisa and Sugar

Source: Internet
Author: User

Codeforces A #264. Caisa and Sugar

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 exceed99, 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? XIRepresents 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 take50 sweets as a change.

Give you n sweets, s dollars. Each candy gives us dollars and cents. When we buy one, the zero cent we get is equivalent to the same number of sweets, ask how much candy you can find

Train of Thought: Just judge'

#include 
 
  #include 
  
   #include 
   
    #include using namespace std;const int maxn = 205;int n, s;int x[maxn], y[maxn];int main() {scanf("%d%d", &n, &s);int ans = -1;for (int i = 0; i < n; i++) {scanf("%d%d", &x[i], &y[i]);if (x[i] < s && y[i] != 0)ans = max(ans, 100 - y[i]);if (x[i] < s && y[i] == 0)ans = max(ans, 0);if (x[i] == s && y[i] == 0)ans = max(ans, 0);}printf("%d\n", ans);}
   
  
 


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.