Codeforce 264 A Caisa and Sugar(简单)

Caisa去商店买Sugar  商店找零的最低单位为元  低于1元的部分每分找一个糖果   商店有n种Suger Caisa有s元钱  她只买一种Sugar  输入n s 再输入n行  每行两个数a b  表示第i种Sugar的单价为a元b分   求Sugar最多能被找多少糖果

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int  n, s, cos;
    while (~scanf ("%d%d", &n, &s))
    {
        s *= 100;
        int flag = 0, a, b, ans = 0;
        while (n--)
        {
            scanf ("%d%d", &a, &b);
            cos = a * 100 + b;
            for (int j = 1; cos * j <= s; ++j)
            {
                flag = 1;
                ans = max (ans, (s - cos) % 100);
            }
        }
        printf ("%d\n", flag ? ans : -1);
    }
    return 0;
}

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 are n 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 xiyi (1?≤?xi?≤?100; 0?≤?yi?<?100),
where xi represents
the number of dollars and yi the
number of cents needed in order to buy the i-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 take 50 sweets
as a change.



时间: 2024-12-28 21:20:30

Codeforce 264 A Caisa and Sugar(简单)的相关文章

Codeforce 264 B Caisa and Pylons(模拟)

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

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 are

Codeforces 463A. 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 are

H.264官方软件JM源代码简单分析-解码器ldecod

前一阵子看了一下H.264官方参考软件JM的源代码,在这里总结一下它的结构.JM编解码H.264的速度相对于FFmpeg来说是非常慢的,但是它的代码写得清晰易懂,更适合做学术方面的研究.JM包含了视频解码器ldecod和视频编码器lencod.本文记录视频解码器ldecod的结构. 函数调用关系图 JM中的H.264视频解码器ldecod的函数调用关系图如下所示.   单击查看更清晰的大图 下面解释一下图中关键标记的含义. 函数背景色函数在图中以方框的形式表现出来.不同的背景色标志了该函数不同的

Codeforces Round #264 (Div. 2)[ABCDE]

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代替,当然能用美元找就尽量用美元找.他

转: 最简单的基于FFmpeg的AVfilter例子(水印叠加)

该例子完成了一个水印叠加的功能.可以将一张透明背景的PNG图片作为水印叠加到一个视频文件上. 1. [代码][C/C++]代码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65

藏妹子之处(excel)

问题描述: 今天CZY又找到了三个妹子,有着收藏爱好的他想要找三个地方将妹子们藏起来,将一片空地抽象成一个R行C列的表格,CZY要选出3个单元格.但要满足如下的两个条件: (1)任意两个单元格都不在同一行. (2)任意两个单元格都不在同一列. 选取格子存在一个花费,而这个花费是三个格子两两之间曼哈顿距离的和(如(x1,y1)和(x,y2)的曼哈顿距离为|x1-x2|+|y1-y2|).狗狗想知道的是,花费在minT到maxT之间的方案数有多少. 答案模1000000007.所谓的两种不同方案是指

我的开源视音频项目汇总

本文汇总一下自己视音频编解码学习方面的开源项目.这些开源项目大体上可以分成专业领域程序,FFmpeg示例程序,FFmpeg移植程序,多媒体项目示例程序,视音频编解码原理学习工程几个类别.这些类别的详细含义如下所列. 专业领域程序:一些有专业性质的程序. FFmpeg示例程序:FFmpeg的类库的各种示例程序. FFmpeg移植程序:FFmpeg项目中移植到Windows的VC平台下的程序. 多媒体项目示例程序:除了FFmpeg之外其他多媒体项目的示例程序. 视音频编解码学习工程:用于学习视音频编

FFmpeg: 最好的音视频处理工具(翻译)

FFmpeg: The ultimate Video and Audio Manipulation Tool(原标题) What is FFmpeg? Chances are you've probably heard of FFmpeg already. It's a set of tools dedicated to decoding, encoding and transcoding video and audio. FFmpeg is based on the popular libav