Codeforces Round #281(Div.2) C. Vasya and Basketball 폭력수 문제
9108 단어 codeforces
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
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.
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 - b is maximum. If there are several such scores, find the one in which number a is maximum.
Sample test(s)
Input
3
1 2 3
2
5 6
Output
9:6
Input
5
6 7 8 9 10
5
1 2 3 4 5
Output
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[1000000];
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=0;i<n1;i++)
{
cin>>num[i].a;
num[i].b=1;
}
int n2;
cin>>n2;
for(int i=0;i<n2;i++)
{
cin>>num[n1+i].a;
num[n1+i].b=2;
}
sort(num,num+n1+n2,cmp);
int ans=0;
int kill=0;
int flag=0;
int flag2=0;
for(int i=0;i<n1+n2;i++)
{
if(num[i].b==2)
ans--;
if(num[i].b==1)
ans++;
if(ans>0)
ans=0;
if(ans==0)
flag=i;
}
int ans1=0;
int ans2=0;
for(int i=0;i<n1+n2;i++)
{
if(i<=flag)
{
if(num[i].b==1)
ans1+=3;
if(num[i].b==2)
ans2+=3;
}
if(i>flag)
{
if(num[i].b==1)
ans1+=2;
if(num[i].b==2)
ans2+=2;
}
}
if(num[flag].b==2)
{
ans2-=1;
}
cout<<ans1<<":"<<ans2<<endl;
return 0;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Codeforces Round #715 Div. 2C The Sports Festival: 구간 DP전형구간 DP의 초전형. 이하, 0-indexed. 입력을 정렬하여 어디서나 시작하고 최적으로 좌우로 계속 유지하면 좋다는 것을 알 수 있습니다. {2000})$의 주문이 된다. 우선, 입력을 소트하여 n개의 요소를 $...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.