Codeforces Round #281 (Div. 2) - C
来源:互联网 发布:米思米 cad数据下载 编辑:程序博客网 时间:2024/06/01 09:46
被坑的地方就是贪心的选法,没错但思维不清晰;
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#define INF 2000001000using namespace std;int n,m;const int maxn = 200100;int a[maxn],b[maxn];int get(int& fen2,int v){int d = v;int p =upper_bound(b,b+m,d)-b;fen2 = 2*(p)+3*(m-p);}int main(){ scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d",&a[i]); scanf("%d",&m); for(int i=0;i<m;i++) scanf("%d",&b[i]); sort(a,a+n); sort(b,b+m); int fen1,fen2; int cha = -INF; if(a[0] > 0){ int d = a[0]-1; fen1 = 3*n; get(fen2,d); cha = fen1 - fen2; } for(int i=0;i<n;i++){ if(i==n-1 || a[i] !=a[i+1]) { //条件很重要 int d = i==n-1 ? INF :a[i+1]-1; int te1 = 2*(i+1)+3*(n-i-1),te2; get(te2,d); if(te1 - te2 > cha ||te1 - te2 ==cha&&fen1<te1){ fen1 = te1; fen2 = te2; cha = te1 - te2; } } } printf("%d:%d\n",fen1,fen2); return 0;}
0 0
- Codeforces Round #281 (Div. 2) C
- Codeforces Round #281 (Div. 2) - C
- 【codeforces】Codeforces Round #370 (Div. 2) C
- Codeforces Round #281 (Div. 2)
- Codeforces Round #281 (Div. 2)
- Codeforces Round #281 (Div. 2)
- Codeforces Round #281 (Div. 2)
- Codeforces Round #281 (Div. 2) A,B,C,D
- Codeforces Round #105 (Div. 2) C
- Codeforces Round 134 div 2 C题
- Codeforces Round #137 (Div. 2), problem: (C)
- Codeforces Round #153 (Div. 2) C题
- Codeforces Round #158 (Div. 2) C题
- Codeforces Round #162 (Div. 2) C
- Codeforces Round #166 (Div. 2) c. Secret
- Codeforces Round#170(Div 2)C
- Codeforces Round #173 (Div. 2) Problem C
- Codeforces Round #192 (Div. 2) C. Purification
- C# 中的常用正则表达式大全
- android真机调试问题 Adb connection Error:远程主机强迫关闭了一个现有的连接
- JavaScript Number Conversion
- ATI 显卡驱动程序安装找不到INF文件(快速安装AMD显卡驱动)
- 在苹果系统上一键安装php环境!
- Codeforces Round #281 (Div. 2) - C
- cocos2dx项目Android编译时,省去手动添加.cpp文件
- 32位操作系统升级为64位步奏
- Android项目的目录结构
- ubuntu如何利用minicom
- Linux mount/unmount命令
- js模块化
- Android事件分发机制完全解析,带你从源码的角度彻底理解(上)
- Mac OS X 10.9.4 系统用HomeBrew安装管理ruby