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 aren 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.
InputThe 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?100), wherexi represents the number of dollars andyi the number of cents needed in order to buy thei-th type of sugar.
OutputPrint 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) Input5 10 3 90 12 0 9 70 5 50 7 0Output
50Input
5 5 10 10 20 20 30 30 40 40 50 50Output
-1Note
In the first test sample Caisa can buy the fourth type of sugar, in such a case he will take50 sweets as a change.
題意:給你n個糖果,s美元,每個糖果給出美元和美分,我們買一種的時候,找回來的零的美分是等價於同數值個數的糖果,問你能找回最多的糖果是多少
思路:判斷就是了‘
#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); }