codeforces A#264. Caisa and Sugar
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.
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 < 100), wherexi represents the number of dollars andyi the number of cents needed in order to buy thei-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 take50 sweets as a change.
제목: n개의 사탕, s달러를 드리겠습니다. 사탕마다 달러와 센트를 드리겠습니다. 우리가 하나를 살 때 찾은 0센트는 같은 수치의 개수와 같은 사탕입니다. 가장 많이 찾을 수 있는 사탕이 얼마냐고 물어보세요.
생각: 판단하면 된다'
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
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
", ans);
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.