题目链接: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. PAT甲级练习题1001、1002

    1001 A+B Format (20 分)   Calculate a+b and output the sum in standard format -- that is, the digits ...

  2. 四个很好的开源app项目

    Open Source and the iOS App Store Today, we are open-sourcing 4 iOS apps: ThatInbox, an email client ...

  3. AndroidStudio怎样导入jar包

    来自:http://jingyan.baidu.com/article/e6c8503c7190b7e54f1a1893.html AndroidStudio用于开发安卓Apk非常地方便,但是它的很多 ...

  4. NFC模组,开发NFC功能 仅仅要几条指令的事情

    特点:实现NFC透明传输.内置NFC协议栈,支持UART串口直接读写,用于门禁能够同一时候兼容手机和卡片开门,还能实现动态密钥,读到的NFC数据自己主动串口输出,会串口就能开发NFC,不须要研究LLC ...

  5. Majority Number

    题目描写叙述 链接地址 解法 算法解释 题目描写叙述 Given an array of integers, the majority number is the number that occurs ...

  6. window.open 打开子窗体,关闭全部的子窗体

    需求:通过window.open方法打开了子窗体,当关闭主窗体时.子窗体应当也关闭. 实现思路: 1.打开子窗体函数window.open(url,winName)的第二个參数winName能够唯一标 ...

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

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

  8. 【转载】C#中的==、Equal、ReferenceEqual

    1. ReferenceEquals, == , Equals Equals , == , ReferenceEquals都可以用于判断两个对象的个体是不是相等. a) ReferenceEquals ...

  9. D堆的实现

    实现上一篇博客(http://blog.csdn.net/buleriver/article/details/38469977)说的D堆.假设把mD设置成2.D堆就退化成二叉堆,也就是说.二叉堆是D堆 ...

  10. 开关电路_MOS和三极管

    https://blog.csdn.net/acelit/article/details/70171312 绍过一般的电源开关电路,控制电源的目的是省电,控制静态电流.不过以下的电路存在着几个缺点:  ...