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这个词 ...
随机推荐
- from setuptools import setup ImportError: No module named setuptools【转】
转自:http://www.cnblogs.com/chinacloud/archive/2010/12/24/1915644.html from setuptools import setupImp ...
- js中字符串的常用方法
一.普通方法 1.字符方法 动态方法:1.str.charAt(index); 返回子字符串,index为字符串下标,index取值范围[0,str.length-1] 动态方法:2.str.cha ...
- Ubuntu 18.04安装MongoDB 4.0(社区版)
Ubuntu 18.04(虚拟机VirtualBox上),MongoDB 4.0, 听室友说,23点有世界杯决赛呢!可是,孤要写博文的啊!以记录这忙乱的下午和晚间成功安装了一个软件到Linux上.—— ...
- MongoDB安全:内置角色概览
官文列举如下(文档不长,过英语四级者可以轻松阅读,就不需要看本文额)(基于MongoDB 3.6的文档,4.0也没有变化): Role-Based Access Control Built-In Ro ...
- netstat-ll-grep-nohup-df-supervisord
============http://man.linuxde.net/=========== 0 vi / n是查找下一个,alt+n是上一个 u撤销上一步,回到上一步 1. 根据进程号(4974) ...
- keras LSTM中间的dropout
TM有三个 model.add(LSTM(100, dropout=0.2, recurrent_dropout=0.2)) 第一个dropout是x和hidden之间的dropout,第二个是hid ...
- java基础62 JavaScript中的函数(网页知识)
1.JavaScript中,函数的格式 function 函数名(形参列表){ 函数体; } 2.JavaScript中,函数需要注意的细节 1.在javaScript中,函数定义形参时,是不能使用v ...
- Codeforces 948C Producing Snow(优先队列+思维)
题目链接:http://codeforces.com/contest/948/problem/C 题目大意:给定长度n(n<=1e5),第一行v[i]表示表示第i堆雪的体积,第二行t[i]表示第 ...
- Unix IPC之Posix消息队列(2)
/* Query status and attributes of message queue MQDES. */ extern int mq_getattr (mqd_t __mqdes, stru ...
- Centos之链接命令
链接命令:ln (link) ln -s [源文件] [目标文件] 功能描述:生成链接文件 选项: -s 创建软链接 硬链接特征: 1,拥有相同的i节点和存储block块,可以看作是同一个文件: 2 ...