博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #281 (Div. 2) C. Vasya and Basketball 二分
阅读量:4582 次
发布时间:2019-06-09

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

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.

Examples
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 思路:我怎么zz的写了个二分;    n*3-n小于等于d的个数-m*2-m大于d的个数最大;    显然需要求n小于等于d的个数+m大于d的个数最小;    我是暴力二分,排个序好像可以把二分取消了;
#include
using namespace std;#define ll long long#define pi (4*atan(1.0))#define eps 1e-14const int N=2e5+10,M=4e6+10,inf=1e9+10,mod=1e9+7;const ll INF=1e18+10;int a[N],b[N],sa,sb;int l[N<<1];int flag,n,m;int check(int x){ int pos1=upper_bound(a,a+n,x)-a; int pos2=upper_bound(b,b+m,x)-b; pos2=m-pos2; return pos1+pos2;}int main(){ flag=0; scanf("%d",&n); for(int i=0;i
ans) lu++; printf("%d:%d",3*n-ji,2*m+lu); return 0;}

 

转载于:https://www.cnblogs.com/jhz033/p/5932399.html

你可能感兴趣的文章
微信小程序 报错: Expecting 'EOF','}',',',']', got INVALID
查看>>
mysql 数据库【目录】
查看>>
开发工具IDEA环境安装配置
查看>>
python3正则表达式详细用法示例
查看>>
算法笔记_086:蓝桥杯练习 9-2 文本加密(Java)
查看>>
Win8下使用Ctrl加空格来切换输入法
查看>>
ajax分页
查看>>
Java 常量池理解与总结(转摘)
查看>>
多线程编程学习笔记——线程池(三)
查看>>
从开始学编程过了半年了……
查看>>
【05月22日】预分红股息率最高排名
查看>>
Android学习总结(二)——Service基本概念和生命周期
查看>>
chr()//ord() //进制转换函数//eval()//文件函数//split()
查看>>
第一章 Java程序设计概述
查看>>
定时调动 (项目保留备份代码码)
查看>>
Leetcode-Divide Two Integers
查看>>
HTML 首页倒三角形导航块
查看>>
每天一道Java题[9]
查看>>
结对编程2——单元测试
查看>>
python 函数/列表的应用
查看>>