【链接】 我是链接,点我呀:)

【题意】

题意

【题解】

枚举三分线(离散后)的位置
然后根据预处理的前缀和,快速算出两个队伍的分数。

【代码】

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int N = 2e5;
  4. int n,m;
  5. int a[N+10],b[N+10],aa[2*N+100],bb[2*N+100];
  6. map<int,int> dic;
  7. map<int,int> dic2;
  8. int main(){
  9. ios::sync_with_stdio(0),cin.tie(0);
  10. cin >> n;
  11. for (int i = 1;i <= n;i++) {
  12. cin >> a[i];
  13. dic[a[i]] = 1;
  14. }
  15. cin >> m;
  16. for (int i = 1;i <= m;i++) {
  17. cin >> b[i];
  18. dic[b[i]] = 1;
  19. }
  20. map<int,int>::iterator it;
  21. int cnt = 0;
  22. dic2[0] = ++cnt;
  23. for (it = dic.begin();it!=dic.end();it++) {
  24. dic2[(*it).first] = ++cnt;
  25. }
  26. for (int i = 1;i <= n;i++){
  27. aa[dic2[a[i]]]++;
  28. }
  29. for (int i = 1;i <= m;i++){
  30. bb[dic2[b[i]]]++;
  31. }
  32. for (int i = 1;i <= cnt;i++) aa[i]+=aa[i-1];
  33. for (int i = 1;i <= cnt;i++) bb[i]+=bb[i-1];
  34. int ans = -(1e8),maxa;
  35. for (int i = 1;i <= cnt;i++){
  36. int ga = aa[i]*2+(n-aa[i])*3;
  37. int gb = bb[i]*2+(m-bb[i])*3;
  38. if (ga-gb>ans){
  39. ans = ga-gb;
  40. maxa = ga;
  41. }else if (ga-gb==ans){
  42. if (maxa<ga){
  43. maxa = ga;
  44. }
  45. }
  46. }
  47. cout<<maxa<<":"<<maxa-ans<<endl;
  48. return 0;
  49. }

【Codeforces 493C】Vasya and Basketball的更多相关文章

  1. 【Codeforces 1030D】Vasya and Triangle

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 参考这篇题解:https://blog.csdn.net/mitsuha_/article/details/82825862 为什么可以保证m ...

  2. 【Codeforces 493D】Vasya and Chess

    [链接] 我是链接,点我呀:) [题意] [题解] 会发现两个皇后之间如果只有奇数个位置 也就是n%2==1 那么第二个人总是赢的 因为如果white往下跑的话,black也能往下跑. 第二个人没有输 ...

  3. 【CodeForces 577C】Vasya and Petya’s Game

    链接 某个数x属于[1,n],至少询问哪些数“x是否是它的倍数”才能判断x.找出所有质因数和质因数的幂即可. #include<cstdio> #include<algorithm& ...

  4. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  5. 【22.70%】【codeforces 591C】 Median Smoothing

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  6. 【23.26%】【codeforces 747D】Winter Is Coming

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  7. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  8. 【codeforces 707C】Pythagorean Triples

    [题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...

  9. 【codeforces 709D】Recover the String

    [题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...

随机推荐

  1. ubuntu 12.04不能mount nfs目录与挂载后只读不能写问题 (转载)

    转自:http://blog.chinaunix.net/uid-20680966-id-3810455.html 服务器用的是fedora 12  以前在helper2416开发板上挂载服务器上的n ...

  2. Tomcat的jvm配置

    Tomcat本身不能直接在计算机上运行,需要依赖于操作系统和一个JAVA虚拟机.Tomcat的内存溢出本质就是JVM内存溢出,JAVA程序启动时JVM会分配一个初始内存和最大内存给程序.当程序需要的内 ...

  3. akka监控框架设计

    本博客介绍一种AOP.无侵入的akka监控方案,方便大家在生产使用akka的过程中对akka进行监控. 对于自身javaer来说,AOP三个字母基本就解释清楚了akka监控框架的原理.哈哈哈,不过我这 ...

  4. Java多线程(六)守护进程

    守护进程:当进程中不存在非守护线程了,则守护线程自动销毁: public class DaemonThread extends Thread{ private int i =0; public voi ...

  5. 233 Number of Digit One 数字1的个数

    给定一个整数 n,计算所有小于等于 n 的非负数中数字1出现的个数. 例如: 给定 n = 13, 返回 6,因为数字1出现在下数中出现:1,10,11,12,13. 详见:https://leetc ...

  6. 待销售分拣单App数据推送

    管理待分拣商品的App的显示操作

  7. Python操作远程数据库

    我的项目要往数据库中插入create_time和update_time,那就势必要引用现在的系统时间,经过大量的查找,终于发现往python是没有对应时间datetime的相关通配符的,那么我们要怎么 ...

  8. QT 杂记

    1.按F4切换designer和Edit视图. 2.加载同目录下的js文件: import "XXX.js" as MyJs //首字母一定要大写 3.qml 引用的js中对象.字 ...

  9. Codeforces_766_C_(dp)

    C. Mahmoud and a Message time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  10. js异步请求

    目前async / await特性并没有被添加到ES2016标准中,但不代表这些特性将来不会被加入到Javascript中.在我写这篇文章时,它已经到达第三版草案,并且正迅速的发展中.这些特性已经被I ...