题目链接: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 解题报告的更多相关文章

  1. codeforces 463B Caisa and Pylons 解题报告

    题目链接:http://codeforces.com/problemset/problem/463/B 题目意思:Caisa 站在 0 pylon 并且只有 0 energy,他需要依次跳过1 pyl ...

  2. Codeforces Educational Round 92 赛后解题报告(A-G)

    Codeforces Educational Round 92 赛后解题报告 惨 huayucaiji 惨 A. LCM Problem 赛前:A题嘛,总归简单的咯 赛后:A题这种**题居然想了20m ...

  3. codeforces 476C.Dreamoon and Sums 解题报告

    题目链接:http://codeforces.com/problemset/problem/476/C 题目意思:给出两个数:a 和 b,要求算出 (x/b) / (x%b) == k,其中 k 的取 ...

  4. Codeforces Round #382 (Div. 2) 解题报告

    CF一如既往在深夜举行,我也一如既往在周三上午的C++课上进行了virtual participation.这次div2的题目除了E题都水的一塌糊涂,参赛时的E题最后也没有几个参赛者AC,排名又成为了 ...

  5. codeforces 507B. Amr and Pins 解题报告

    题目链接:http://codeforces.com/problemset/problem/507/B 题目意思:给出圆的半径,以及圆心坐标和最终圆心要到达的坐标位置.问最少步数是多少.移动见下图.( ...

  6. codeforces 500B.New Year Permutation 解题报告

    题目链接:http://codeforces.com/problemset/problem/500/B 题目意思:给出一个含有 n 个数的排列:p1, p2, ..., pn-1, pn.紧接着是一个 ...

  7. codeforces B. Xenia and Ringroad 解题报告

    题目链接:http://codeforces.com/problemset/problem/339/B 题目理解不难,这句是解题的关键 In order to complete the i-th ta ...

  8. codeforces 462C Appleman and Toastman 解题报告

    题目链接:http://codeforces.com/problemset/problem/461/A 题目意思:给出一群由 n 个数组成的集合你,依次循环执行两种操作: (1)每次Toastman得 ...

  9. codeforces 460A Vasya and Socks 解题报告

    题目链接:http://codeforces.com/problemset/problem/460/A 题目意思:有一个人有 n 对袜子,每天早上会穿一对,然后当天的晚上就会扔掉,不过他会在 m 的倍 ...

随机推荐

  1. G 全然背包

    <span style="color:#3333ff;">/* /* _________________________________________________ ...

  2. Android HandlerThread 消息循环机制之源代码解析

    关于 HandlerThread 这个类.可能有些人眼睛一瞟,手指放在键盘上,然后就是一阵狂敲.立即就能敲出一段段华丽的代码: HandlerThread handlerThread = new Ha ...

  3. LattePanda 项目之 P2.2 起飞条件检测系统(CLI & GUI)

    前言 原创文章,转载引用务必注明链接,水平有限,如有疏漏,欢迎指正. 本文使用Markdown写成,为获得更好的阅读体验和正常的链接.图片显示,请访问我的博客原文: http://www.cnblog ...

  4. angular - 小结

    引入样式: 导入全局 - >styles.css 导入第三方 - > 在package.json配置,然后再 npm install 安装好以后,最后再angular.json里面的sty ...

  5. angular - 使用es6等一些功能

    app.module.ts var model = { user: 'Admin', items: [{ action: 'buy flowsers', done: false },{ action: ...

  6. Hibernate中的session和load延迟载入矛盾问题,怎样解决?

    假设延迟载入出现session close的情况下 方法1.在web.xml中配置spring的openSessionInViewFilter <filter>  <filter-n ...

  7. centos创建本地yum仓库

    怎样发布自己软件的安装和更新YUM源 在创建之前,我们先了解些相关的内容: yum仓库可以支持三种途径提供给yum在安装的时候下载rpm包 第一种:  ftp服务  ftp:// 第二种:  http ...

  8. CentOS Linux搭建独立SVN Server全套流程(转)

    环境为centos6.3 1.首先 看看机器上安装了svn了没有 rpm -qa |grep svn 2.如果没有安装 执行 yum -y install subversion 3.安装好了之后 新建 ...

  9. ReboletricSample工程搭建

    受到  Just Say No to More End-to-End Tests 文章链接:http://googletesting.blogspot.tw/2015/04/just-say-no-t ...

  10. 在“云基础设施即服务的魔力象限”报告中,AWS 连续三年被评为领导者

    在"2014 云基础设施即服务的魔力象限"中.Gartner 将 Amazon Web Services 定位在"领导者象限"中,并评价 AWS 拥有最完整.最 ...