题目链接: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. html5-css动画-2d

    div{    width: 300px;    height: 100px;    margin: 50px;    padding: 50px;    background: green;     ...

  2. Spark核心RDD:combineByKey函数详解

    https://blog.csdn.net/jiangpeng59/article/details/52538254 为什么单独讲解combineByKey? 因为combineByKey是Spark ...

  3. C#-----创建DataTable对象

    //DataTable表示内存中数据的一个表 DataTable dt = new DataTable(); /** * public DataColumn Add(string columnName ...

  4. python os.path.expanduser()

    # Expand the user's home directory

  5. CSS 选择器权重计算规则

    其实,CSS有自己的优先级计算公式,而不仅仅是行间>内部>外部样式:ID>class>元素. 一.样式类型 1.行间 <h1 style="font-size: ...

  6. 算法训练 P0505

    一个整数n的阶乘可以写成n!,它表示从1到n这n个整数的乘积.阶乘的增长速度非常快,例如,13!就已经比较大了,已经无法存放在一个整型变量中:而35!就更大了,它已经无法存放在一个浮点型变量中.因此, ...

  7. 安装DotNetCore.1.0.0-VS2015Tools.Preview2一直失败,如何解?

    首先要说明的一点是,本地的VS2015的环境已经安装完成,而且vs2015.3也已经更新完成了,这个环境应该是没啥问题.但是安装.DotNetCore.1.0.0-VS2015Tools.Previe ...

  8. AURO OtoSys IM100 vs Lonsdor K518ISE: which better?

    Comparison: AURO OtoSys IM100 and Lonsdor K518ISE It’s aimed to help make a purchase of decent auto ...

  9. Twemproxy和Redis性能压力测试

    性能测试 Redis自带了一个叫 redis-benchmark的工具来模拟N个客户端同时发出M个请求,(类似于Apache ab程序),你可以使用redis-benchmark -h来查看基准参数. ...

  10. 导弹拦截 p1020

    第一问就是求最长不上升子序列的长度,要写O(nlogn)的算法.... 对于这种nlogn的算法,只能求出长度,不能求出具体的序列.这种算法实现过程如下: 我们定义len为到目前为止最长不上升子序列的 ...