Codeforces Round #281 (Div. 2) C. Vasya and Basketball 排序
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 subtractiona - b is 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
///meek
#include<bits/stdc++.h>
using namespace std; typedef long long ll;
#define mem(a) memset(a,0,sizeof(a))
#define pb push_back
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){
if(ch=='-')f=-;ch=getchar();
}
while(ch>=''&&ch<=''){
x=x*+ch-'';ch=getchar();
}return x*f;
}
//****************************************
const int N=;
#define mod 10000007
#define inf 2000000007
#define maxn 10000 ll lna,lnm,n,a[N],b[N],m; struct ss{
ll x,in,index;
}s[N+N];
struct sss {
ll x,aa;
int in;
}W[N+N];
int cmp(ss s1,ss s2) {
if(s1.x==s2.x) return s1.in<s2.in;
return s1.x<s2.x;
}
int cmp2(sss s1,sss s2) {
if(s1.x==s2.x) return s1.aa<s2.aa;
else return s1.x<s2.x;
}
int main() { n=read();
int k=;
for(int i=;i<=n;i++) {
scanf("%I64d",&a[i]);
s[++k].x=a[i];
s[k].in=;
s[k].index=i;
}
m=read();
for(int i=;i<=m;i++) {
scanf("%I64d",&b[i]);
s[++k].x=b[i];
s[k].in=;
s[k].index=i;
}
sort(s+,s+k+,cmp);
ll l=,r=;
for(int i=;i<=k;i++) {
if(s[i].in==) {
l++;
}
else r++;
W[i].x=(l*+(n-l)*)-(r*+(m-r)*);
W[i].aa=(l*+(n-l)*);
W[i].in=i;
}
W[++k].x=n*-m*;
W[k].aa=(n*);
W[k].in=-;
W[++k].x=n*-m*;
W[k].aa=(n*);
W[k].in=-;
sort(W+,W+k+,cmp2);
ll ansl=,ansr=;
ansl=W[k].aa;ansr=W[k].aa-W[k].x;
cout<<ansl<<":"<<ansr<<endl;
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 time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- 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这个词 ...
随机推荐
- [Windows Server 2012] Filezilla安全加固方法
★ 欢迎来到[护卫神·V课堂],网站地址:http://v.huweishen.com ★ 护卫神·V课堂 是护卫神旗下专业提供服务器教学视频的网站,每周更新视频. ★ 本节我们将带领大家:FileZ ...
- 从JavaScript的单线程执行说起
先看一段代码: 1 2 3 4 5 setTimeout(function(){ alert("a"); }, 0); while(1); alert("b&qu ...
- (转)Arcgis for javascript实现百度地图ABCD marker的效果
概述: 在我的博客中,有一篇相关的文章,这段时间,有很多人问我求源码,只是时间过去已长,源代码已找不到,乘着这个9.3放假,又重新实现了下,并相关代码做了优化,在此贴出来,方便大家使用. 相关文章地址 ...
- C#工具帮助类
md5帮助类 .引入库 using System.Security.Cryptography;//引用Md5转换功能 .计算字符串的Md5值 public static string GetMD5Wi ...
- Cat VS Dog HDU_3829(最大独立集最大匹配)
Cat VS Dog 题意:一群小朋友去动物园,如果每个小朋友喜欢的动物是猫,那么不喜欢的动物一定是狗,反之也是.现在动物园的管理者要拿走一些动物,如果拿走的是某个小朋友不喜欢的动物,那这个小朋友就非 ...
- Tomcat启动失败--Several ports (8005, 8080, 8009)
启动Tomcat服务器报错: Several ports (8005, 8080, 8009) required by Tomcat v7.0 Server at localhost are alre ...
- Spring 注解注入的几种方式(转)
平常的java开发中,程序员在某个类中需要依赖其它类的方法,则通常是new一个依赖类再调用类实例的方法,这种开发存在的问题是new的类实例不好统一管理,spring提出了依赖注入的思想,即依赖类不由程 ...
- 使用官方组件下载图片,保存到MySQL数据库,保存到MongoDB数据库
需要学习的地方,使用官方组件下载图片的用法,保存item到MySQL数据库 需要提前创建好MySQL数据库,根据item.py文件中的字段信息创建相应的数据表 1.items.py文件 from sc ...
- 优化JAVA查询Mongodb数量过大,查询熟读慢的方法
前言:2018年的时候优化了一个项目,该项目从MOngodb中获取数据的时候一次去十万百万千万的数据过慢,往往每次都要二十秒,三十秒,今天提出了一个代码优化的方案 项目查从mongodb中获取数据:代 ...
- PAT 1114 Family Property
This time, you are supposed to help us collect the data for family-owned property. Given each person ...