codeforces A#264. Caisa and Sugar

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.

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 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美元,每个糖果给出美元和美分,我们买一种的时候,找回来的零的美分是等价于同数值个数的糖果,问你能找回最多的糖果是多少

思路:判断就是了‘

#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

点击复制链接 与好友分享!回本站首页
您对本文章有什么意见或着疑问吗?请到论坛讨论您的关注和建议是我们前行的参考和动力
上一篇:Lifting the Stone(求任意多边形的重心)
下一篇:Codeforce 264 B Caisa and Pylons(模拟)
相关文章

Codeforces Round #124 (Div. 2)

Codeforces Round #131 (Div. 2)

CodeForces 180E Cubes--后续指针--

Codeforces Round #133 (Div. 2)

CodeForces Round #125 (198C) -

CodeForces Round #116 (180E) - Cubes

CodeForces Round #118 (185A) - Plant

CodeForces Round #118 - Mushroo

CodeForces Round #119 (187A)

CodeForces Round #119 (187B) -

图文推荐
codeforces A#264. Caisa and Sugar
ZOJ 3640 Help Me
codeforces A#264. Caisa and Sugar
CF 518C(Anya and
codeforces A#264. Caisa and Sugar
hdu 1016 Prime R
UVA - 11987 - A

分类:默认分类 时间:2013-03-27 人气:1
本文关键词:
分享到:

相关文章

  • Codeforce 264 A Caisa and Sugar(简单) 2012-09-21

    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

  • Codeforce 264 B Caisa and Pylons(模拟) 2012-11-29

     题意 Caisa走台阶 有n个台阶 第i个台阶的高度为h[i] 从第i个台阶包括地面到下一个台阶得到的能量为h[i]-h[i+1] 能量不足以跳到下一个台阶就要补充能量 求Caisa跳完所有台阶最少要补充多少能量 水题 直接模拟 #include #include using namespace std; const int N = 100005; int h[N]; int main() { int n, e, ans; scanf("%d",&n); for (int i =

  • Codeforces Round #264 (Div. 2)[ABCDE] 2013-09-28

    Codeforces Round #264 (Div. 2)[ABCDE] ACM 题目地址: Codeforces Round #264 (Div. 2) 这场只出了两题TAT,C由于cin给fst了,D想到正解快敲完了却game over了... 掉rating掉的厉害QvQ... A - Caisa and Sugar【模拟】 题意: Caisa拿s美元去超市买sugar,有n种sugar,每种为xi美元yi美分,超市找钱时不会找美分,而是用sweet代替,当然能用美元找就尽量用美元找。他

  • Codeforces 463E Caisa and Tree dfs+分解质因素 2013-10-31

    题目链接:点击打开链接 题意: 给了一棵树 每个点有点权 操作1 : 1 u 表示询问 gcd(Valueof(u), Valueof(v) ) != 1 的所有v 点中深度最大的点 [ v是 path(u, root); && v!=u ] 操作2 : 2 u w 修改点权 思路: 因为操作2的个数不超过50个,所以每次更新点权后都把所有答案预处理一遍。这样回答是O(1), 更新是n*logn*logn 每次在dfs中计算答案和更新素数栈,dfs完子树后就把这个点在栈里删掉,这

  • codeforces B#264. Caisa and Pylons 2013-09-15

    Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (n?+?1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with numberi

  • Codeforces 432 D. Prefixes and Suffixes 2012-01-10

    ?ㄦ?╁?KMP??绠???????.... D. Prefixes and Suffixes time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have a string s????em>s1s2...s|s|, where |s| is the length of string s, and si its i-t

  • CodeForces 374 A. Inna and Pink Pony 2012-03-01

    一定要考虑全面啊。。。。。 A. Inna and Pink Pony time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Dima and Inna are doing so great! At the moment, Inna is sitting on the magic lawn playing with a pink po

  • Codeforces 493A. Vasya and Football 水 2012-04-20

    A. Vasya and Football time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya has started watching football games. He has learned that for some fouls the players receive yellow cards, and fo

  • Codeforces 388 C. Fox and Card Game 2012-10-15

    C. Fox and Card Game time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Fox Ciel is playing a card game with her friend Fox Jiro. There are n piles of cards on the table. And there is a positi

Copyright (C) quwantang.com, All Rights Reserved.

趣玩堂 版权所有 京ICP备15002868号

processed in 0.054 (s). 10 q(s)