【Codeforces 493C】Vasya and Basketball
【链接】 我是链接,点我呀:)
【题意】
题意
【题解】
枚举三分线(离散后)的位置
然后根据预处理的前缀和,快速算出两个队伍的分数。
【代码】
#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的更多相关文章
- 【Codeforces 1030D】Vasya and Triangle
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 参考这篇题解:https://blog.csdn.net/mitsuha_/article/details/82825862 为什么可以保证m ...
- 【Codeforces 493D】Vasya and Chess
[链接] 我是链接,点我呀:) [题意] [题解] 会发现两个皇后之间如果只有奇数个位置 也就是n%2==1 那么第二个人总是赢的 因为如果white往下跑的话,black也能往下跑. 第二个人没有输 ...
- 【CodeForces 577C】Vasya and Petya’s Game
链接 某个数x属于[1,n],至少询问哪些数“x是否是它的倍数”才能判断x.找出所有质因数和质因数的幂即可. #include<cstdio> #include<algorithm& ...
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【22.70%】【codeforces 591C】 Median Smoothing
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【23.26%】【codeforces 747D】Winter Is Coming
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【codeforces 707E】Garlands
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...
- 【codeforces 707C】Pythagorean Triples
[题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...
- 【codeforces 709D】Recover the String
[题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...
随机推荐
- ubuntu 12.04不能mount nfs目录与挂载后只读不能写问题 (转载)
转自:http://blog.chinaunix.net/uid-20680966-id-3810455.html 服务器用的是fedora 12 以前在helper2416开发板上挂载服务器上的n ...
- Tomcat的jvm配置
Tomcat本身不能直接在计算机上运行,需要依赖于操作系统和一个JAVA虚拟机.Tomcat的内存溢出本质就是JVM内存溢出,JAVA程序启动时JVM会分配一个初始内存和最大内存给程序.当程序需要的内 ...
- akka监控框架设计
本博客介绍一种AOP.无侵入的akka监控方案,方便大家在生产使用akka的过程中对akka进行监控. 对于自身javaer来说,AOP三个字母基本就解释清楚了akka监控框架的原理.哈哈哈,不过我这 ...
- Java多线程(六)守护进程
守护进程:当进程中不存在非守护线程了,则守护线程自动销毁: public class DaemonThread extends Thread{ private int i =0; public voi ...
- 233 Number of Digit One 数字1的个数
给定一个整数 n,计算所有小于等于 n 的非负数中数字1出现的个数. 例如: 给定 n = 13, 返回 6,因为数字1出现在下数中出现:1,10,11,12,13. 详见:https://leetc ...
- 待销售分拣单App数据推送
管理待分拣商品的App的显示操作
- Python操作远程数据库
我的项目要往数据库中插入create_time和update_time,那就势必要引用现在的系统时间,经过大量的查找,终于发现往python是没有对应时间datetime的相关通配符的,那么我们要怎么 ...
- QT 杂记
1.按F4切换designer和Edit视图. 2.加载同目录下的js文件: import "XXX.js" as MyJs //首字母一定要大写 3.qml 引用的js中对象.字 ...
- Codeforces_766_C_(dp)
C. Mahmoud and a Message time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- js异步请求
目前async / await特性并没有被添加到ES2016标准中,但不代表这些特性将来不会被加入到Javascript中.在我写这篇文章时,它已经到达第三版草案,并且正迅速的发展中.这些特性已经被I ...