codeforces 463A Caisa and Sugar 解题报告
题目链接:http://codeforces.com/problemset/problem/463/A
题目意思:某个人有 s dollar的钱,有 n 种类型的糖果,第 i 种糖果的价值为 xi dollar + yi cent。这个商场比较古怪,如果收了顾客的cent,它不会找回相应的cent,而是用对应的sweet来替代。这个人只可以买一种类型的糖果,前提是 s dollar 大于等于糖果的价值,问最多可以得到的sweet是多少。
有几个细节需要注意:
(1)如果够钱买,但是糖果的cent 为 0,这个人是得不到任何sweet!
(2)判断够不够钱买糖果的时候,不能只单纯看dollar,而要看埋对应的cent。例如这组数据:
1 10
10 10
这个人是买不起这种糖果的!
(3)sweet 数 = 100 - yi(前提是买得起)
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std; const int maxn = + ; struct node
{
int x, y;
bool operator < (const node& a) const
{
return x < a.x;
} }sugar[maxn]; int main()
{
int s, n;
while (scanf("%d%d", &n, &s) != EOF)
{
for (int i = ; i < n; i++)
scanf("%d%d", &sugar[i].x, &sugar[i].y);
sort(sugar, sugar+n);
int ans = ;
int flag = ;
for (int i = ; i < n; i++)
{
if (sugar[i].x > s)
break;
else if (sugar[i].x == s && sugar[i].y > ) // 对应情况2
continue;
else
{
if (sugar[i].y == ) // 对应第一种情况
ans = max(ans, );
else
ans = max(ans, -sugar[i].y);
flag = ;
}
}
printf("%d\n", flag ? ans : -);
}
return ;
}
codeforces 463A Caisa and Sugar 解题报告的更多相关文章
- codeforces 463B Caisa and Pylons 解题报告
题目链接:http://codeforces.com/problemset/problem/463/B 题目意思:Caisa 站在 0 pylon 并且只有 0 energy,他需要依次跳过1 pyl ...
- Codeforces Educational Round 92 赛后解题报告(A-G)
Codeforces Educational Round 92 赛后解题报告 惨 huayucaiji 惨 A. LCM Problem 赛前:A题嘛,总归简单的咯 赛后:A题这种**题居然想了20m ...
- codeforces 476C.Dreamoon and Sums 解题报告
题目链接:http://codeforces.com/problemset/problem/476/C 题目意思:给出两个数:a 和 b,要求算出 (x/b) / (x%b) == k,其中 k 的取 ...
- Codeforces Round #382 (Div. 2) 解题报告
CF一如既往在深夜举行,我也一如既往在周三上午的C++课上进行了virtual participation.这次div2的题目除了E题都水的一塌糊涂,参赛时的E题最后也没有几个参赛者AC,排名又成为了 ...
- codeforces 507B. Amr and Pins 解题报告
题目链接:http://codeforces.com/problemset/problem/507/B 题目意思:给出圆的半径,以及圆心坐标和最终圆心要到达的坐标位置.问最少步数是多少.移动见下图.( ...
- codeforces 500B.New Year Permutation 解题报告
题目链接:http://codeforces.com/problemset/problem/500/B 题目意思:给出一个含有 n 个数的排列:p1, p2, ..., pn-1, pn.紧接着是一个 ...
- codeforces B. Xenia and Ringroad 解题报告
题目链接:http://codeforces.com/problemset/problem/339/B 题目理解不难,这句是解题的关键 In order to complete the i-th ta ...
- codeforces 462C Appleman and Toastman 解题报告
题目链接:http://codeforces.com/problemset/problem/461/A 题目意思:给出一群由 n 个数组成的集合你,依次循环执行两种操作: (1)每次Toastman得 ...
- codeforces 460A Vasya and Socks 解题报告
题目链接:http://codeforces.com/problemset/problem/460/A 题目意思:有一个人有 n 对袜子,每天早上会穿一对,然后当天的晚上就会扔掉,不过他会在 m 的倍 ...
随机推荐
- 1004 Counting Leaves
A family hierarchy is usually presented by a pedigree tree. Your job is to count those family member ...
- react-redux的connect()方法
容器组件使用 connect() 方法连接 Redux 我们用 react-redux 提供的 connect() 方法将“笨拙”的 Counter 转化成容器组件.connect() 允许你从 Re ...
- NoSQL数据库-MongoDB和Redis
http://blog.csdn.net/tea_wu/article/details/19050277 http://www.uml.org.cn/sjjm/201212205.asp
- 建立第一个Sencha Touch应用
准备 开始开发前,请先到下面的地址下载Sencha Touch 2的包:http://www.sencha.com/products/touch/download/ .下载完解压后你会发现包里有很多文 ...
- https双向认证訪问管理后台,採用USBKEY进行系统訪问的身份鉴别,KEY的证书长度大于128位,使用USBKEY登录
近期项目需求,须要实现用USBKEY识别用户登录,採用https双向认证訪问管理后台管理界面,期间碰到过一些小问题,写出来给大家參考下. 1:前期准备工作 USBKEY 硬件:我买的是飞天诚信 epa ...
- request 发送多层字典
a. 客户端向服务端发送多层字典的值 #客户端发送 obj = { 'data':{ "k1":"v1", "k2":"v2&qu ...
- VueJS处理逻辑指令:v-if
HTML <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <titl ...
- 做QA的日子——iOS測试入门(四)
坦言,做QA的这半年我没有成长,就算有成长也非常少,我非常难过.和身边的人讲事实上并没有谁能真正理解自己的难过,事实上还是自己不够努力.对自己不够狠,以前认为自己不够幸运,想有一个更好的指路人,事实上 ...
- sublime 汇总
此文内容有原创,还有各种其他博客抄来的经验,技巧,纯属个人使用心得. http://www.cnblogs.com/figure9/p/sublime-text-complete-guide.html ...
- mini2440使用jlink烧写superboot到norflash
Jlink版本号:J-flash ARM V4.12 J-Flash ARM的配置. 一般说来file-->open project里面会找到一些*.jfl ...