Codeforces Round #281 (Div. 2) C. Vasya and Basketball 二分
2 seconds
256 megabytes
standard input
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.
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).
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.
3
1 2 3
2
5 6
9:6
5
6 7 8 9 10
5
1 2 3 4 5
15:10
思路:我怎么zz的写了个二分;
n*3-n小于等于d的个数-m*2-m大于d的个数最大;
显然需要求n小于等于d的个数+m大于d的个数最小;
我是暴力二分,排个序好像可以把二分取消了;
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi (4*atan(1.0))
#define eps 1e-14
const int N=2e5+,M=4e6+,inf=1e9+,mod=1e9+;
const ll INF=1e18+;
int a[N],b[N],sa,sb;
int l[N<<];
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=;
scanf("%d",&n);
for(int i=;i<n;i++)
scanf("%d",&a[i]),l[flag++]=a[i];
scanf("%d",&m);
for(int i=;i<m;i++)
scanf("%d",&b[i]),l[flag++]=b[i];
sort(a,a+n);
sort(b,b+m);
l[flag++]=;
l[flag++]=2e9+;
sort(l,l+flag);
flag=unique(l,l+flag)-l;
int minn=inf,ans;
for(int i=;i<flag;i++)
{
int v=check(l[i]);
if(v<minn)
{
minn=v;
ans=l[i];
}
}
int ji=,lu=;
for(int i=;i<n;i++)
if(a[i]<=ans)
ji++;
for(int i=;i<m;i++)
if(b[i]>ans)
lu++;
printf("%d:%d",*n-ji,*m+lu);
return ;
}
Codeforces Round #281 (Div. 2) C. Vasya and Basketball 二分的更多相关文章
- Codeforces Round #281 (Div. 2) C. Vasya and Basketball 暴力水题
C. Vasya and Basketball time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- Codeforces Round #281 (Div. 2) C. Vasya and Basketball 排序
C. Vasya and Basketball Vasya follows a basketball game and marks the distances from which each te ...
- Codeforces Round #281 (Div. 2) B. Vasya and Wrestling 水题
B. Vasya and Wrestling 题目连接: http://codeforces.com/contest/493/problem/B Description Vasya has becom ...
- Codeforces Round #281 (Div. 2) D. Vasya and Chess 水
D. Vasya and Chess time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #281 (Div. 2) D. Vasya and Chess 镜面对称 博弈论
D. Vasya and Chess time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #281 (Div. 2) A. Vasya and Football 暴力水题
A. Vasya and Football time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- Codeforces Round #281 (Div. 2) D. Vasya and Chess 博弈
D. Vasya and Chess Vasya decided to learn to play chess. Classic chess doesn't seem interesting to ...
- Codeforces Round #281 (Div. 2) A. Vasya and Football 暴力
A. Vasya and Football Vasya has started watching football games. He has learned that for some foul ...
- Codeforces Round #281 (Div. 2) A. Vasya and Football(模拟)
简单题,却犯了两个错误导致WA了多次. 第一是程序容错性不好,没有考虑到输入数据中可能给实际已经罚下场的人再来牌,这种情况在system测试数据里是有的... 二是chronologically这个词 ...
随机推荐
- How to create UrlSlug in Asp.Net MVC
转自:http://www.ehsanghanbari.com/Post/20/how-to-create-urlslug-in-aspnet-mvc UrlSlug Is a way of gene ...
- $IFS和set
$IFS是内部字段分隔符的缩写.它决定Bash解析字符串时将怎样识别字段,或单词分界线.默认为(空格.制表符.换号) 修改$IFS: [xiluhua@vm-xiluhua][~/shell_scri ...
- mysql btree与hash索引的适用场景和限制
btree索引: 如果没有特别指明类型,多半说的就是btree索引,它使用btree数据结构来存储数据,大多数mysql引擎都支持这种索引,archive引擎是一个例外,5.1之前这个引擎不支持任何索 ...
- 20145227《Java程序设计》课程总结
20145227<Java程序设计>课程总结 每周读书笔记链接汇总 20145227 <Java程序设计>第1周学习总结 20145227 <Java程序设计>第2 ...
- ACM题目————Robot Motion
Description A robot has been programmed to follow the instructions in its path. Instructions for the ...
- office 2013 产品秘钥
9RN4T-JPBQV-XQMC9-PM9FP-PGWP9 TKX7J-VDN26-Y2WKQ-7MG8R-X2CC9 N9M8X-QDKGK-W27Q6-2GQYT-TJC9K 4VNXV-F7PB ...
- winform之自定义控件
这样的一个控件 肯定得通过自定义控件来实现了 public class ProcessLabel : Control { public ProcessLabel() { //InitializeCom ...
- js获取页面高度赋值给div
<script type="text/javascript"> window.onload=function(){ map_width=document.body.cl ...
- 精通D3.js学习笔记(2)比例尺和坐标
1.线性比例尺 d3.scale.linear() 创建一个线性比例尺 .domain([0,500]) 定义域 .range([0,1000]) 值域 l ...
- Android中@id与@+id区别
Android中的组件需要用一个int类型的值来表示,这个值也就是组件标签中的id属性值. id属性只能接受资源类型的值,也就是必须以@开头的值,例如,@id/abc.@+id/xyz等. 如果在@后 ...