题目链接:http://codeforces.com/problemset/problem/276/A

从这n个输入中求最大值,注意 和 k的比较,定义一个maxn,对每个输入进行计算即可。

AC代码:

#include<cstdio>
#include<climits> using namespace std; /* 获取int型数据的最大值最小值有两种方式
* 第一种是利用头文件<climits>
* 第二种直接定义或者宏定义
* INT_MAX = 2147483647
* INT_MIN = -2147483648
* #define INT_MAX 0x7fffffff
* #define INT_MIN 0x80000000
*/ int n, k;
int x, y;
int maxn, temp; int main() {
while (scanf("%d%d", &n, &k) != EOF) {
maxn = INT_MIN;
while (n--) {
scanf("%d%d", &x, &y);
if (y > k) {
temp = x - (y - k);
} else
temp = x;
if (maxn < temp)
maxn = temp;
}
printf("%d\n", maxn);
}
return 0;
}

[CodeForces - 276A] Lunch Rush的更多相关文章

  1. Codeforces Zepto Code Rush 2014 -C - Dungeons and Candies

    这题给的一个教训:Codeforces没有超时这个概念.本来以为1000*(1000+1)/2*10*10要超时的.结果我想多了. 这题由于k层都可能有关系,所以建一个图,每两个点之间连边,边权为n* ...

  2. CodeForceS#276-A

    A. Factory   One industrial factory is reforming working plan. The director suggested to set a mythi ...

  3. CodeForces ZeptoLab Code Rush 2015

    拖了好久的题解,想想还是补一下吧. A. King of Thieves 直接枚举起点和5个点之间的间距,进行判断即可. #include <bits/stdc++.h> using na ...

  4. Codeforces - ZeptoLab Code Rush 2015 - D. Om Nom and Necklace:字符串

    D. Om Nom and Necklace time limit per test 1 second memory limit per test 256 megabytes input standa ...

  5. Codeforces ZeptoLab Code Rush 2015 D.Om Nom and Necklace(kmp)

    题目描述: 有一天,欧姆诺姆发现了一串长度为n的宝石串,上面有五颜六色的宝石.他决定摘取前面若干个宝石来做成一个漂亮的项链. 他对漂亮的项链是这样定义的,现在有一条项链S,当S=A+B+A+B+A+. ...

  6. Codeforces Round #169 (Div. 2)

    A. Lunch Rush 模拟. B. Little Girl and Game 因为可以打乱顺序,所以只关心每种数字打奇偶性. 若一开始就是回文,即奇数字母为0或1种,则先手获胜. 若奇数字母大于 ...

  7. Codeforces Round #169 (Div. 2) A水 B C区间更新 D 思路

    A. Lunch Rush time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  8. Codeforces Gym 100637B B. Lunch 找规律

    B. Lunch Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100637/problem/B Des ...

  9. Codeforces 1136D - Nastya Is Buying Lunch - [贪心+链表+map]

    题目链接:https://codeforces.com/problemset/problem/1136/D 题意: 给出 $1 \sim n$ 的某个排列 $p$,再给出若干 $(x,y)$ 表示当序 ...

随机推荐

  1. 实战http切换成https

    Server端使用Nginx + Tomcat Niginx SSL on Tomcat SSL non 步骤: 1.修改代码,将外部引用的http js css 文件修改为https,若外部链接不支 ...

  2. 获取 web 服务器 port

    Tomcat: public static String getServerPort(boolean secure) throws AttributeNotFoundException, Instan ...

  3. 大数据和hadoop有什么关系?

    本文资料来自百度文库相关文档 Hadoop,Spark和Storm是目前最重要的三大分布式计算系统,Hadoop常用于离线的复杂的大数据处理,Spark常用于离线的快速的大数据处理,而Storm常用于 ...

  4. sqlyog下载

    sqlyog下载(附注册码):http://www.onlinedown.net/soft/24926.htm

  5. linux常用命令:touch 命令

    linux的touch命令不常用,一般在使用make的时候可能会用到,用来修改文件时间戳,或者新建一个不存在的文件. 1.命令格式: touch [选项]... 文件... 2.命令参数: -a    ...

  6. Linux基础命令---arch

    Arch         Arch指令主要用于显示当前主机的硬件结构类型,我们可以看到它输出的结果有:i386.i486.mips.alpha等.此命令的适用范围:RedHat.RHEL.Ubuntu ...

  7. Java中在java.sql.Date的系统时间上加上30天并写入oracle

    在java.sql.Date的系统时间上加上30天,并写入oracle 思路:通过 Calendar.getInstance() 获得对象,然后 add() 方法添加 时间,再通过 new java. ...

  8. MySQL日志详细说明

    这片博文我们会详细说明MySQL本身的日志,不包含重做日志和undo日志(这两个日志是innodb存储引擎的日志). MySQL本身的日志有以下几种(MySQL5.7版本): 错误日志 慢查询日志 通 ...

  9. asyncio 学习

    来自:https://www.syncd.cn/article/asyncio_article_02 一.asyncio之—-入门初探 通过上一篇关于asyncio的整体介绍,看过之后基本对async ...

  10. redmine3.2 的部署

    安装libyaml [root@ ~]#wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz -O /dist/dist/yaml-0.1 ...