Vasya and Basketball CodeForces - 493C
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.
Example
3
1 2 3
2
5 6
9:6
5
6 7 8 9 10
5
1 2 3 4 5
15:10 两支队伍a,b,a进了n球 下面n个数为a队进球距离球筐的距离,
b进了m球,下面m个数为b队进球距离球筐的距离,
问三分线为多少时a队与b队的比分差值最大
输出比分 答案优先输出a大的。 temp1=upper_bound(a,a+n,a[i])-a;
temp1=temp1*2+(n-temp1)*3;
upper_bound返回的是第一个大于a[i]的元素的指针,
数组从0开始,所以temp对应的就是小于a[i]的元素的个数
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;
int a[],b[];
int main() {
int n,m,x,y;
while(scanf("%d",&n)!=EOF){
for (int i= ;i<n ;i++) scanf("%d",&a[i]);
scanf("%d",&m);
for (int i= ;i<m ;i++) scanf("%d",&b[i]);
if (n>=m) {
x=*n;
y=*m;
}else {
x=*n;
y=*m;
}
int temp1,temp2;
sort(a,a+n);
sort(b,b+m);
for (int i= ;i<n ;i++ ){
temp1=upper_bound(a,a+n,a[i])-a;
temp2=upper_bound(b,b+m,a[i])-b;
temp1=temp1*+(n-temp1)*;
temp2=temp2*+(m-temp2)*;
if (temp1-temp2==x-y){
if (temp1>x){
x=temp1;
y=temp2;
}
}else if (temp1-temp2>x-y){
x=temp1;
y=temp2;
}
}
for (int i= ;i<m ;i++ ){
temp1=upper_bound(a,a+n,b[i])-a;
temp2=upper_bound(b,b+m,b[i])-b;
temp1=temp1*+(n-temp1)*;
temp2=temp2*+(m-temp2)*;
if (temp1-temp2==x-y){
if (temp1>x){
x=temp1;
y=temp2;
}
}else if (temp1-temp2>x-y){
x=temp1;
y=temp2;
}
}
printf("%d:%d\n",x,y);
}
return ;
}
Vasya and Basketball CodeForces - 493C的更多相关文章
- Codeforces 493C - Vasya and Basketball
C. Vasya and Basketball 题目链接:http://codeforces.com/problemset/problem/493/C time limit per test 2 se ...
- 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 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 ...
- cf493C Vasya and Basketball
C. Vasya and Basketball time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- 【Codeforces 493C】Vasya and Basketball
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 枚举三分线(离散后)的位置 然后根据预处理的前缀和,快速算出两个队伍的分数. [代码] #include <bits/stdc++.h& ...
- codeforces 493 C Vasya and Basketball
题意:给出三分线的值d,分别有两支队伍,如果小于等于d,得2分,如果大于d,得三分,问使得a-b最大时的a,b 一看到题目,就想当然的去二分了----啥都没分出来---55555555 后来才知道不能 ...
- Vasya and Multisets CodeForces - 1051C(英语限制了我的想象力)
题意: 对输入的每个数都进行分配到两个多重集中,问分配完以后 每个多重集中的个数为1的元素是否相等 相等则输出一个分配方式, 不想等为NO 解析: 三种情况 1.原数列中个数为1 的数的个数为偶数 ...
- Vasya and Shifts CodeForces - 832E (高斯消元)
大意: 给定$4n$个$m$位的五进制数, $q$个询问, 每个询问给出一个$m$位的五进制数$b$, 求有多少种选数方案可以使五进制异或和为$b$. 高斯消元入门题 每次询问相当于就是给定了$m$个 ...
随机推荐
- BZOJ 4766: 文艺计算姬 [矩阵树定理 快速乘]
传送门 题意: 给定一个一边点数为n,另一边点数为m,共有n*m条边的带标号完全二分图$K_{n,m}$ 求生成树个数 1 <= n,m,p <= 10^18 显然不能暴力上矩阵树定理 看 ...
- InnoDB索引
名词解释 clustered index(聚集索引) 对(primary key)主键索引的一种表述.InnoDB表存储是基于primary key列来组织的,这样做可以加快查询和排序速度.为了获得最 ...
- 【非原创】C++类成员函数的重载、覆盖和隐藏
链接:https://www.nowcoder.com/questionTerminal/266d3a6d4f1b436aabf1eff3156fed95来源:牛客网 题目:类成员函数的重载.覆盖和隐 ...
- Python中的浅拷贝与深拷贝
编者注:本文主要参考了<Python核心编程(第二版)> 以下都是参考资料后,我自己的理解,如有错误希望大家不吝赐教. 大家有没有遇到这样一种情况,对象赋值后,对其中一个变量进行修改,另外 ...
- Phalcon调试大杀器之phalcon-debugbar安装
Phalcon 是一款非常火的高性能C扩展php开发框架.特点是高性能低耦合,但遗憾的是长期缺少一款得力的调试辅助工具. 目前版本主要以Laravel debugbar的具有功能为蓝本开发,并针对ph ...
- LeetCode - 492. Construct the Rectangle
For a web developer, it is very important to know how to design a web page's size. So, given a speci ...
- 本地创建yum源并安装lnmp
注意:安装系统时,文件类型要未xfs类型,root要分配最多的空间 1.挂载安装光盘mount -t iso9660 -o loop CentOS-7-x86_64-DVD-1511.iso /mnt ...
- Docker Centos6 下建立 Docker 桥接网络
cd /etc/sysconfig/network-scripts/; cp ifcfg-eth0 ifcfg-br0 vi ifcfg-eth0 //增加BRIDGE=br0,删除IPADDR,N ...
- Ubuntu下利用Apache转发模块实现反向代理
Apache的反向代理主要利用转发模块,proxy和proxy_http 先配置 Apache 支持proxy 和 proxy_http 在Ubuntu系统下,Apache的配置文件在目录/etc/a ...
- mysql有多条记录的单个字段想存为一个字段显示的方法
SELECT po.id,(SELECT GROUP_CONCAT(mr.member_type) as memberTypeList FROM prod_offer_member_rel mr WH ...