`
阿尔萨斯
  • 浏览: 4200709 次
社区版块
存档分类
最新评论

Codeforces 463A Caisa and Sugar(水题)

 
阅读更多

题目链接: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;
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics