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

【题意】

题意

【题解】

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

【代码】

#include <bits/stdc++.h>
using namespace std;
const int N = 2e5; int n,m;
int a[N+10],b[N+10],aa[2*N+100],bb[2*N+100];
map<int,int> dic;
map<int,int> dic2; int main(){
ios::sync_with_stdio(0),cin.tie(0);
cin >> n;
for (int i = 1;i <= n;i++) {
cin >> a[i];
dic[a[i]] = 1;
}
cin >> m;
for (int i = 1;i <= m;i++) {
cin >> b[i];
dic[b[i]] = 1;
}
map<int,int>::iterator it;
int cnt = 0;
dic2[0] = ++cnt;
for (it = dic.begin();it!=dic.end();it++) { dic2[(*it).first] = ++cnt;
}
for (int i = 1;i <= n;i++){
aa[dic2[a[i]]]++;
} for (int i = 1;i <= m;i++){
bb[dic2[b[i]]]++;
}
for (int i = 1;i <= cnt;i++) aa[i]+=aa[i-1];
for (int i = 1;i <= cnt;i++) bb[i]+=bb[i-1];
int ans = -(1e8),maxa;
for (int i = 1;i <= cnt;i++){
int ga = aa[i]*2+(n-aa[i])*3;
int gb = bb[i]*2+(m-bb[i])*3;
if (ga-gb>ans){
ans = ga-gb;
maxa = ga;
}else if (ga-gb==ans){
if (maxa<ga){
maxa = ga;
}
}
}
cout<<maxa<<":"<<maxa-ans<<endl; return 0;
}

【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. Vue Router过渡动效

    <router-view> 是基本的动态组件,所以我们可以用 <transition> 组件给它添加一些过渡效果: <transition> <router- ...

  2. 6章 Models

    传统的MVC结构中,有模型这么一个概念.Django中,Models又是怎么一回事呢? 刚才生成的这些乱七八糟的数据迁移就是Django自带的一些应用 INSTALLED_APPS = [ 'djan ...

  3. bzoj 1034: [ZJOI2008]泡泡堂BNB【贪心】

    是贪心 先把两个数组排序,然后贪心的选让a数组占优的(如果没有就算输),这是最大值,最小值是2n-贪心选b数组占优 #include<iostream> #include<cstdi ...

  4. Windows 和 Linux 上Redis的安装守护进程配置

    # Windows 和 Linux 上Redis的安装守护进程配置 Redis 简介 ​ Redis是目前最常用的非关系型数据库(NOSql)之一,常以Key-Value的形式存储.Redis读写速度 ...

  5. Proteus中的 PIC10/12/16 MCUs编译器无法下载的问题

    当你打开网站时,点击该软件下载会发现如下页面: google一下会出现这个界面,大意是这个版本的编译器太老了,已经被某些更加高级的编译器给取代了(qaq心痛) 然后我就开始FQ到处google,Sou ...

  6. 最大流增广路(KM算法) HDOJ 2255 奔小康赚大钱

    题目传送门 /* KM:裸题第一道,好像就是hungary的升级版,不好理解,写点注释 KM算法用来解决最大权匹配问题: 在一个二分图内,左顶点为X,右顶点为Y,现对于每组左右连接Xi,Yj有权w(i ...

  7. php pdo oracle

    <?php/** * Created by mestars. * User: mestars * Date: 6/13/16 * Time: 10:52 PM */header('Access- ...

  8. C# 文件操作(摘抄)

    ——选自<c# 编程兵书>第11章 张志强 胡君 编著 11 文件操作概述 11.1 驱动器 在Windows操作系统中,存储介质统称为驱动器,硬盘由于可以划分为多个区域,每一个区域称为一 ...

  9. 关于定位中left和right,top和bottom的权重问题

    关于定位中left和right,top和bottom的权重问题 在共同类中设置了定位并且设置了left等定位,如果你引用这个类并加入其他的类中也有left和right等定位,那么你设置的right或是 ...

  10. PendingIntent 显示通知

    安卓显示通知 PendingIntent pendingIntent=PendingIntent.getActivity(Media.this,0, new Intent(Media.this,Med ...