日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Codeforces Round #281 (Div. 2) C. Vasya and Basketball 二分

發布時間:2025/3/20 编程问答 15 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Codeforces Round #281 (Div. 2) C. Vasya and Basketball 二分 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

C. Vasya and Basketball

題目連接:

http://codeforces.com/contest/493/problem/C

Description

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 Input

3
1 2 3
2
5 6

Sample Output

9:6

Hint

題意

A隊在n個距離位置投進了籃球,B隊在m個位置。

現在讓你來劃3分線,然后使得A隊分數減去B隊分數最大。

題解:

暴力枚舉三分線,肯定三分線就n+m+4種可能,都暴力枚舉一邊,然后對于每一個隊伍,我二分找到有多少個二分球,和多少個三分球就好了

代碼

#include<bits/stdc++.h> using namespace std; const int maxn = 2e5+7; int n,m; int a[maxn],b[maxn]; int Ans=-1e9,Ans2,Ans3; void update(int x,int y,int z) {if(Ans<x)Ans=x,Ans2=y,Ans3=z;if(Ans==x&&y>Ans2)Ans=x,Ans2=y,Ans3=z; } void get(int x) {int l=0,r=m,ans=1;while(l<=r){int mid=(l+r)/2;if(b[mid]<=x)ans=mid,l=mid+1;else r=mid-1;}int l2=0,r2=n,ans2=1;while(l2<=r2){int mid=(l2+r2)/2;if(a[mid]<=x)ans2=mid,l2=mid+1;else r2=mid-1;}update(ans2*2+(n-ans2)*3-ans*2-(m-ans)*3,ans2*2+(n-ans2)*3,ans*2+(m-ans)*3); } int main() {scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%d",&a[i]);scanf("%d",&m);for(int i=1;i<=m;i++)scanf("%d",&b[i]);sort(a+1,a+1+n);sort(b+1,b+1+m);update(2*n-2*m,2*n,2*m);update(3*n-3*m,3*n,3*m);for(int i=1;i<=n;i++)get(a[i]);get(a[1]-1);get(a[n]+1);for(int i=1;i<=m;i++)get(b[i]);get(b[1]-1);get(b[m]+1);printf("%d:%d\n",Ans2,Ans3); }

轉載于:https://www.cnblogs.com/qscqesze/p/5844267.html

總結

以上是生活随笔為你收集整理的Codeforces Round #281 (Div. 2) C. Vasya and Basketball 二分的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。