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 - 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
5
6 7 8 9 10
5
1 2 3 4 5
15:10 NOTE
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
struct point{
int a;
int b;
};
point num[];
bool cmp(point a,point b)
{
if(a.a==b.a)
return a.b>b.b;
return a.a>b.a;
}
bool cmp1(point a,point b)
{
if(a.a==b.a)
return a.b<b.b;
return a.a>b.a;
}
int main()
{
int n1;
cin>>n1;
for(int i=;i<n1;i++)
{
cin>>num[i].a;
num[i].b=;
}
int n2;
cin>>n2;
for(int i=;i<n2;i++)
{
cin>>num[n1+i].a;
num[n1+i].b=;
}
sort(num,num+n1+n2,cmp);
int ans=;
int kill=;
int flag=;
int flag2=;
for(int i=;i<n1+n2;i++)
{
if(num[i].b==)
ans--;
if(num[i].b==)
ans++;
if(ans>)
ans=;
if(ans==)
flag=i;
}
int ans1=;
int ans2=;
for(int i=;i<n1+n2;i++)
{
if(i<=flag)
{
if(num[i].b==)
ans1+=;
if(num[i].b==)
ans2+=;
}
if(i>flag)
{
if(num[i].b==)
ans1+=;
if(num[i].b==)
ans2+=;
}
}
if(num[flag].b==)
{
ans2-=;
}
cout<<ans1<<":"<<ans2<<endl;
return ;
}
Codeforces Round #281 (Div. 2) C. Vasya and Basketball 暴力水题的更多相关文章
- 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) 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) 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这个词 ...
随机推荐
- Mysql_Learning_Notes_系统结构_1_数据类型
数据类型 整型 1.tinyint 1Bytes -128~127(255) 2.smallint 2Bytes -32768~32676(65535) 3.mdeiumint 3Bytes -838 ...
- MsSqlserver 查看锁表与解锁
查看被锁表: select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) tableName from sys. ...
- dorado 的学习位置、控件使用方法查找、示例演示地址
dorado的学习位置: http://wiki.bsdn.org/display/dorado7/Project+Home dorado的控件使用方法查找: http://dorado7.bsdn. ...
- 02 How to Write Go Code 如何编写go语言代码
How to Write Go Code 如何编写go语言代码 Introduction 介绍 Code organization 组织代码 Overview 概述 Workspaces ...
- Java代码优化总结
代码优化是一个很重要的课题.一般来说,代码优化的目标主要有两个,一个是减小代码的体积,另一个是提高代码运行的效率. 代码优化的细节有很多,此处列举部分: 1.尽量指定类.方法的final修饰符. 带有 ...
- 浅谈js设计模式之单例模式
单例模式的定义是:保证一个类仅有一个实例,并提供一个访问它的全局访问点. 单例模式是一种常用的模式,有一些对象我们往往只需要一个,比如线程池.全局缓存.浏览器中的 window 对象等.在 JavaS ...
- python基础学习之路No.1
版本python2 python语言不分"和',两者可以一样使用,同等效果 1.输出print python3中print是一个函数 print "hello world" ...
- 使用JS实现2048小游戏
JS实现2048小游戏源码 效果图: 代码如下,复制即可使用: (适用浏览器:360.FireFox.Chrome.Opera.傲游.搜狗.世界之窗. 不支持Safari.IE8及以下浏览器.) &l ...
- GLOBAL_NAMES参数研究
最近在配置Stream时,发现必须要把GLOBAL_NAMES参数的指设置为TRUE,具体原因为何不知.但是发现在设置了该参数之后,数据库每天的物化视图刷新出现了问题.之后查明原因,是DBLINK出现 ...
- Python基础 - 系统进程调用
subprocess模块 近期发现还有一个更好的用于取代subprocess的库,sh,也是openstack当中使用的库.