Codeforces Round #281 (Div. 2) C. Vasya and Basketball
2014-12-08 00:42
435 查看
C. Vasya and Basketball
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
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 test(s)
input
output
input
output
枚举二分
View Code
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
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 test(s)
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 <bits/stdc++.h> using namespace std; typedef long long LL; const int maxn = 2e5 + 10; #define rep(i,a,b) for(int i=(a);i<=(b);i++) LL A[maxn], B[maxn]; int main() { LL n, m; while(cin >> n) { for(int i = 1; i <= n; ++i) cin >> A[i]; cin >> m; for(int i = 1; i <= m; ++i) cin >> B[i]; sort(A + 1, A + 1 + n); sort(B + 1, B + 1 + m); LL a = 0, b = 0, s = INT_MIN, x; LL res1 = 0, res2 = 0; A[n + 1] = 2e9 + 7; for(LL i = 1; i <= n + 1; i++) { a = 2 * (i - 1) + 3 * (n - i + 1); if(i > 1 && A[i] == A[i - 1] && i != n + 1)continue; x = lower_bound(B + 1, B + 1 + m, A[i]) - B; if(B[x] >= A[i]) x--; if(x < 0) x = 0; if(x > m) x = m; b = x * 2 + (m - x) * 3; if(i == n + 1) { a = 2 * n, b = 2 * m; } if(a - b == s && a > res1) { res1 = a, res2 = b; } if(a - b > s) { s = a - b; res1 = a, res2 = b; } } if(res1 < 0) res1 = 0; if(res2 < 0) res2 = 0; cout << res1 << ':' << res2 << endl; } return 0; }
View Code
相关文章推荐
- Codeforces Round #281 (Div. 2) C. Vasya and Basketball 枚举+二分
- Codeforces Round #281 (Div. 2) C. Vasya and Basketball 二分
- Codeforces #281 (Div. 2)C Vasya and Basketball(二分)
- Codeforces #281 (Div. 2)C Vasya and Basketball(二分)
- Codeforces Round #281 (Div. 2) C. Vasya and Basketball
- Codeforces Round 281 div2 C Vasya and Basketball
- Codeforces Round #281 (Div. 2) C. Vasya and Basketball&D. Vasya and Chess
- Codeforces Round #281 (Div. 2) C. Vasya and Basketball 排序
- Codeforces Round #281 (Div. 2) C. Vasya and Basketball 暴力水题
- Codeforces Round #281 (Div. 2) C. Vasya and Basketball 二分
- Codeforces Round #354 (Div. 2) C .Vasya and String
- Codeforces Round #262 (Div. 2) A. Vasya and Socks
- Codeforces Round #354 (Div. 2) - C. Vasya and String
- CodeForce #319 div 2 C Vasya and Petya's Game
- Codeforces Round #281 (Div. 2) A. Vasya and Football 模拟
- Codeforces Round #281 (Div. 2) A. Vasya and Football(模拟)
- Codeforces Round #354 (Div. 2) C Vasya and String(尺取法二分)
- Codeforces Round #324 (Div. 2) Marina and Vasya 乱搞推理
- codeforces水题100道 第十五题 Codeforces Round #262 (Div. 2) A. Vasya and Socks (brute force)
- [思路题] Codeforces 354C #206 (Div. 1) C. Vasya and Beautiful Arrays