zoukankan      html  css  js  c++  java
  • Vasya and Basketball CodeForces

    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 - bis maximum. If there are several such scores, find the one in which number a is maximum.

    Example

    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

    两支队伍a,b,a进了n球 下面n个数为a队进球距离球筐的距离,
    b进了m球,下面m个数为b队进球距离球筐的距离,
    问三分线为多少时a队与b队的比分差值最大
    输出比分 答案优先输出a大的。

    temp1=upper_bound(a,a+n,a[i])-a;
    temp1=temp1*2+(n-temp1)*3;
    upper_bound返回的是第一个大于a[i]的元素的指针,
    数组从0开始,所以temp对应的就是小于a[i]的元素的个数
     1 #include<cstdio>
     2 #include<cstring>
     3 #include<cmath>
     4 #include<algorithm>
     5 #include<queue>
     6 using namespace std;
     7 int a[200010],b[200010];
     8 int main() {
     9     int n,m,x,y;
    10     while(scanf("%d",&n)!=EOF){
    11         for (int i=0 ;i<n ;i++) scanf("%d",&a[i]);
    12         scanf("%d",&m);
    13         for (int i=0 ;i<m ;i++) scanf("%d",&b[i]);
    14         if (n>=m) {
    15             x=3*n;
    16             y=3*m;
    17         }else {
    18             x=2*n;
    19             y=2*m;
    20         }
    21         int temp1,temp2;
    22         sort(a,a+n);
    23         sort(b,b+m);
    24         for (int i=0 ;i<n ;i++ ){
    25             temp1=upper_bound(a,a+n,a[i])-a;
    26             temp2=upper_bound(b,b+m,a[i])-b;
    27             temp1=temp1*2+(n-temp1)*3;
    28             temp2=temp2*2+(m-temp2)*3;
    29             if (temp1-temp2==x-y){
    30                 if (temp1>x){
    31                     x=temp1;
    32                     y=temp2;
    33                 }
    34             }else if (temp1-temp2>x-y){
    35                 x=temp1;
    36                 y=temp2;
    37             }
    38         }
    39         for (int i=0 ;i<m ;i++ ){
    40             temp1=upper_bound(a,a+n,b[i])-a;
    41             temp2=upper_bound(b,b+m,b[i])-b;
    42             temp1=temp1*2+(n-temp1)*3;
    43             temp2=temp2*2+(m-temp2)*3;
    44             if (temp1-temp2==x-y){
    45                 if (temp1>x){
    46                     x=temp1;
    47                     y=temp2;
    48                 }
    49             }else if (temp1-temp2>x-y){
    50                 x=temp1;
    51                 y=temp2;
    52             }
    53         }
    54         printf("%d:%d
    ",x,y);
    55     }
    56     return 0;
    57 }


  • 相关阅读:
    H3C BGP配置10BGP安全功能典型配置举例
    H3C BGP配置9调整和优化BGP网络典型配置举例1BGP负载分担配置
    H3C BGP配置11 BGP网络的可靠性典型配置举例1BGP GR配置
    H3C BGP配置9调整和优化BGP网络典型配置举例2BGP AddPath配置
    vue移动端适配postcsspxtorem
    .net 技术站点(转载)
    邯郸.net俱乐部
    存储过程从入门到熟练(多个存储过程完整实例及调用方法)_AX 转载
    gridview中删除记录的处理
    邯郸.NET俱乐部正式成立了
  • 原文地址:https://www.cnblogs.com/qldabiaoge/p/8516570.html
Copyright © 2011-2022 走看看