GYM 100247 J. The Best Statement(水~)
来源:互联网 发布:武汉理工网络教育2017 编辑:程序博客网 时间:2024/05/23 17:01
Description
有n次考试,A和B的得分分别是a[i]和b[i],A有一个心理预期k,只有一场考试的分数大于等于k而且比上一次分数高,这次考试才算数,B可以改变A的想法来设定任意k,问B如何设定k才能使得至少有一次考试算数且B在这些算数的考试中获得的最高分
Input
第一行一整数n表示考试数量,之后n行每行两个整数a[i]和b[i]分别表示A和B的分数(1<=n<=200000,1<=a[i],b[i]<=1e9)
Output
输出B在这些算数的考试中可以获得的最高分
Sample Input
3
3 3
4 6
2 5
Sample Output
6
Solution
水,拿出a序列的单增子列找到这个子列中b[i]的最大值即可
Code
#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<queue>#include<map>#include<set>#include<ctime>using namespace std;typedef long long ll;#define INF 0x3f3f3f3fint n,a,b,ansa,ansb; int main(){ while(~scanf("%d",&n)) { ansa=ansb=0; while(n--) { scanf("%d%d",&a,&b); if(a>ansa) { ansa=a; ansb=max(ansb,b); } } printf("%d\n",ansb); } return 0;}
0 0
- GYM 100247 J. The Best Statement(水~)
- GYM 101149 E.The Best among Equals(水~)
- GYM 100712 J.Candy(水~)
- GYM 101061 J.Cola(水~)
- Codeforces Gym 100379J Move the (p, q)-knight to the corner!(DP+lucas定理)
- GYM 100801J Journey to the “The World's Start”
- Gym 100917J Judgement(dp+bitset)
- Gym 100886J Sockets(二分+贪心)
- GYM 100030 J.Secret Laboratory(SPFA)
- GYM 100090 J.Product Innovation(链表)
- GYM 100883 J.palprime(枚举)
- GYM 101149 J.Panoramic Photography(贪心)
- GYM 101086 J.Smooth Developer(dfs)
- GYM 100694 J.Ticket Booking(贪心)
- Codeforces Gym 101142 J. Java2016 (构造)
- Gym - 100203J Journeys on the Moscow Underground
- GYM Amman 17 J. Spilt the String 模拟,枚举
- GYM 100247 A. The Power of the Dark Side(水~)
- CentOS 7中利用Snapper快照进行系统备份与恢复
- Python系列之二_Python基本语法
- QT和Mysql的第一次连接
- 第八次笔记
- Android图解浅析事件拦截机制
- GYM 100247 J. The Best Statement(水~)
- centos linux,/dev/mapper/vg_pvm-lv_root 磁盘满/root full
- RxJava系列6(从微观角度解读RxJava源码)
- 阿里巴巴Java开发手册(正式版)
- jQuery事件绑定与事件委托
- 双态运维联盟(BOA)正式成立
- 【译】Nodejs最好的ORM
- git 基本操作
- JVM工具命令使用初探