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这个词 ...
随机推荐
- fc26 url
aarch64 http://linux.yz.yamagata-u.ac.jp/pub/linux/fedora-projects/fedora-secondary/releases/26/Ever ...
- 金蝶K3,名称或代码在系统中已被使用,由于数据移动,未能继续以NOLOCK方式扫描
使用金蝶K3时出现:名称或代码在系统中已被使用:错误代码:3604(E14H)source:Microsoft OLE DB provider for SQL SERVERDetail:由于数据移动, ...
- CSS--布局模型,颜色值,长度值
目录 布局模型 流动模型(Flow) 浮动模型 (Float) 层模型(Layer) 颜色值 长度值 一.布局模型 网页布局模型:个人理解,就是对html中各个元素进行一个排列.而排列的方法可以分为 ...
- Java工程师知识图谱
一.Java工程师知识图谱(思维导图版) 二.Java工程师知识图谱(图文版) 三.Java工程师知识图谱(文字版) http://note.youdao.com/noteshare?id=615da ...
- MySQL学习笔记:创建整年日期
见识到另外一种创意,惊讶! 1.创建小数据表 0-9 # 创建小数据表 DROP TABLE IF EXISTS aa_numbers_small; CREATE TABLE aa_numbers_s ...
- canvas 笔记整理
canvas Retina 屏幕优化 /** * HiDPI Canvas Polyfill (1.0.9) * * Author: Jonathan D. Johnson (http://jonda ...
- TCP和UDP的9个区别是什么
TCP和UDP是两个传输层协议,广泛应用于网络中不同主机之间传输数据.对任何程序员来说,熟悉TCP和UDP的工作方式都是至关重要的.这就是为什么TCP和UDP是一个流行的Java编程面试问题.我曾经在 ...
- 解决Linux中文显示乱码的问题
1.直接执行 export LC_ALL=zh_CN.UTF8 #linux服务器中文显示乱码,但配置文件设置是中文的.解决办法 2.修改文件 修改/etc/sysconfig/i18n文件,确认信息 ...
- MySQL 相关知识细节及解析
1,删除表中所有记录使用delete from 表名:还是用truncate table 表名 删除方式:delete 一条一条删除,不清空auto_increment记录数 truncate 直接将 ...
- sql中循环插入
#!/bin/sh for i in {1..10}dokdsql sys/kdb<<EOF insert into test values(2) ; EOFdone