贪心-Codeforces Round #404 (Div. 2)
来源:互联网 发布:免费 刻录软件 编辑:程序博客网 时间:2024/05/21 18:39
看到最大值,就以为是用二分。但是一直超时。
主要是自己solve的方式不对,每次solve都要0n2,来判断是否有大于当前mid的距离。得不偿失。。
一开始暴力写,没有考虑先后顺序,,其实再改动一下就对了。。
哎,too young too naive。。
问题要分析清楚,套路才耍的号。。
两种情况,一种是象棋在前,另一种
#include <iostream>#include <cstdio>#include <cstdlib>#include <algorithm>typedef long long ll;using namespace std;ll a[200006];ll b[200006];ll a1[200006];ll b1[200006];int main(){ int m,n; scanf("%d",&m); for(int i=0;i<m;i++) { scanf("%lld%lld",&a1[i],&a[i]); } sort(a,a+m); sort(a1,a1+m); scanf("%d",&n); for(int i=0;i<n;i++) scanf("%lld%lld",&b[i],&b1[i]); sort(b,b+n); sort(b1,b1+n); ll mm=max(a1[m-1]-b1[0],b[n-1]-a[0]); if(mm<=0) printf("0\n"); else printf("%lld\n",mm); return 0;}
0 0
- 贪心-Codeforces Round #404 (Div. 2)
- Codeforces Round #202 (Div. 2)B-贪心
- Codeforces Round #211 (Div. 2)(二分贪心)
- 【贪心】Codeforces Round #339 (Div. 2) D
- Codeforces Round #351 Div. 2 D 贪心
- Codeforces Round #311 (Div. 2) C 贪心
- Codeforces Round #363 (Div. 2)-C--贪心
- Codeforces Round #303 (Div. 2) D 贪心
- Codeforces Round #370 (Div. 2) C 贪心
- Codeforces Round #375 (Div. 2) C (贪心)
- Codeforces Round #378 (Div. 2) D 贪心
- Codeforces Round #428 (Div. 2) B 贪心
- Codeforces Round #404 (Div. 2)
- Codeforces Round #404 (Div. 2)
- Codeforces Round #404 (Div. 2)
- Codeforces Round #404 (Div. 2)
- Codeforces Round #199 (Div. 2) A ( 简单贪心 )
- Codeforces Round #205 (Div. 2) / 353C Find Maximum (贪心)
- TextView控件设置空字符串的必要
- UVALive 3942 字典树+dp
- centos安装nodejs环境
- VC中线程事件详解
- Cookie与Session的区别-总结很好的文章
- 贪心-Codeforces Round #404 (Div. 2)
- C++作业5
- 二分贪心—B
- SQL总结---连表查询
- C++实现委托机制之完整代码实现
- PAT 乙级 1018
- 5.3
- Oracle问题总结
- AndroidStudio 中如何查看获取MD5和SHA1值(应用签名)