程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> Codeforce 264 A Caisa and Sugar(簡單)

Codeforce 264 A Caisa and Sugar(簡單)

編輯:C++入門知識

Codeforce 264 A Caisa and Sugar(簡單)


Caisa去商店買Sugar 商店找零的最低單位為元 低於1元的部分每分找一個糖果 商店有n種Suger Caisa有s元錢 她只買一種Sugar 輸入n s 再輸入n行 每行兩個數a b 表示第i種Sugar的單價為a元b分 求Sugar最多能被找多少糖果


#include
#include
#include
using namespace std;
int main()
{
    int  n, s, cos;
    while (~scanf ("%d%d", &n, &s))
    {
        s *= 100;
        int flag = 0, a, b, ans = 0;
        while (n--)
        {
            scanf ("%d%d", &a, &b);
            cos = a * 100 + b;
            for (int j = 1; cos * j <= s; ++j)
            {
                flag = 1;
                ans = max (ans, (s - cos) % 100);
            }
        }
        printf ("%d\n", flag ? ans : -1);
    }
    return 0;
}

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 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).

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 integers n,?s (1?≤?n,?s?≤?100).

The i-th of the next n lines contains two integers xi, yi (1?≤?xi?≤?100; 0?≤?yi?xi represents the number of dollars and yi the number of cents needed in order to buy the i-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 10
3 90
12 0
9 70
5 50
7 0
output
50
input
5 5
10 10
20 20
30 30
40 40
50 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.






  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved