题目链接:Codeforces 463E Caisa and Sugar
题目大意:Caisa去超市买东西,有s美元,一美元等于100每分,现在给定n种商品的价格x美元y美分,超市找零是用糖果替代美分,一美分一颗糖果,Caisa想要尽量多的糖果。
解题思路:水题,遍历一遍即可,注意判断x=s的时候。
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main () {
int n, s, ans = -1, x, y;
scanf("%d%d", &n, &s);
for (int i = 0; i < n; i++) {
scanf("%d%d", &x, &y);
if (x < s || (x == s && y == 0))
ans = max(ans, y == 0 ? 0 : 100 - y);
}
printf("%d\n", ans);
return 0;
}