博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforce 493c
阅读量:6484 次
发布时间:2019-06-23

本文共 3036 字,大约阅读时间需要 10 分钟。

H - Vasya and Basketball
Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u
Submit     

Description

Vasya follows a basketball game and marks the distances from which each team makes a throw. He knows that each successful throw has value of either 2 or 3 points. A throw is worth 2 points if the distance it was made from doesn't exceed some value of d meters, and a throw is worth 3 points if the distance is larger than d meters, where d is some non-negative integer.

Vasya would like the advantage of the points scored by the first team (the points of the first team minus the points of the second team) to be maximum. For that he can mentally choose the value of d. Help him to do that.

Input

The first line contains integer n (1 ≤ n ≤ 2·105) — the number of throws of the first team. Then follow n integer numbers — the distances of throws ai (1 ≤ ai ≤ 2·109).

Then follows number m (1 ≤ m ≤ 2·105) — the number of the throws of the second team. Then follow m integer numbers — the distances of throws of bi (1 ≤ bi ≤ 2·109).

Output

Print two numbers in the format a:b — the score that is possible considering the problem conditions where the result of subtraction a - bis maximum. If there are several such scores, find the one in which number a is maximum.

Sample Input

Input
3 1 2 3 2 5 6
Output
9:6
Input
5 6 7 8 9 10 5 1 2 3 4 5
Output
15:10
#include 
#include
#include
#include
using namespace std;typedef long long LL;const int N = 200005;LL n, m, a[N], b[N], mi, mj, ans;int main(){ scanf("%I64d", &n); for(int i = 0; i < n; ++i) scanf("%I64d", &a[i]); scanf("%I64d", &m); for(int i = 0; i < m; ++i) scanf("%I64d", &b[i]); sort(a, a + n); sort(b, b + m); mi = n * 3; mj = m * 3; ans = mi - mj; for(int i = 0; i < n; ++i) { if(a[i] == a[i + 1] && i != n - 1) continue;//注意例子 5 2 2 2 2 2 3 2 2 2, 说明在枚举一串的时候, 相同值的应该用上界来尝试 LL d = a[i]; LL pos = upper_bound(b, b + m, d) - b;//注意uuper_bound 求上界的时候, 如果找到了, 还是返回 最后那个位置 + 1, 而如果要找的数大于数组里面的max, 返回的是 最大下标 LL aa = (i + 1) * 2 + (n - i - 1) * 3; LL bb; if(d >= b[m - 1]) bb = 2 * m; else bb = (pos) * 2 + (m - pos) * 3; if(aa - bb > ans || (aa - bb == ans && aa > mi)) { ans = aa - bb; mi = aa; mj = bb; } } for(int i = 0; i < m; ++i) { if(b[i] == b[i + 1] && i != m - 1) continue; LL d = b[i]; LL pos2 = upper_bound(a, a + n, d) - a; LL bb = (i + 1) * 2 + (m - i - 1) * 3; LL aa; if(d >= a[n - 1]) aa = 2 * n; else aa = (pos2) * 2 + (n - pos2) * 3; if(aa - bb > ans || (aa - bb == ans && aa > mi)) { ans = aa - bb; mi = aa; mj = bb; // printf("[%d %d %d]\n", ans, mi, mj); } } printf("%I64d:%I64d\n", mi, mj);}

  

转载于:https://www.cnblogs.com/orchidzjl/p/4664035.html

你可能感兴趣的文章
MongoDB的基础使用
查看>>
进程间通信——命名管道
查看>>
ssh登陆不需要密码
查看>>
java mkdir()和mkdirs()区别
查看>>
OSChina 周六乱弹 ——揭秘后羿怎么死的
查看>>
IT人员的职业生涯规划
查看>>
sorry,you must have a tty to run sudo
查看>>
ios开发中使用正则表达式识别处理字符串中的URL
查看>>
项目中的积累,及常见小问题
查看>>
Python类型转换、数值操作(收藏)
查看>>
oracle11g dataguard 安装手册(转)
查看>>
1. Two Sum - Easy - Leetcode解题报告
查看>>
多线程---同步函数的锁是this(转载)
查看>>
百练 2742 统计字符数 解题报告
查看>>
Ubuntu搜狗输入法候选词乱码
查看>>
js中回调函数写法
查看>>
React native android 最常见的10个问题
查看>>
数据结构和算法
查看>>
[pat]1045 Favorite Color Stripe
查看>>
Immutable学习及 React 中的实践
查看>>