【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子列的个数; 然后让你输出 ...
随机推荐
- 【158】◀▶ Linux-Bash学习
鸟哥的 Linux 私房菜 Linux 的 26 个命令 Shell 脚本教程 Linux 命令大全 目录——按文件顺序: echo:显示变量内容 printf:格式化输 ...
- 3-1 todolist功能开发
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Objective-C 声明属性
创建: 2018/01/24 完成: 2018/01/25 遗留: TODO 声明属性(declared property) 属性的声明与功能 属性的声明 @property 读写 @proper ...
- VBScript+SCR+NetApi+Accoreconsole 批处理dwg文件
继上次powershell运行accoreconsole(https://www.cnblogs.com/NanShengBlogs/p/10981687.html)的研究之后又觉得不是很合适,毕竟p ...
- RabbitMQ学习之Work Queues(2)
目录: 轮询调度(Round-robin dispatching):即依次分配分配任务给worker. 消息答复(Message acknowledgement):在consumer处理完之后,进行消 ...
- 乐搏讲自动化测试- Python环境搭建(7)
Python的下载和安装 Python可应用于多平台包括 Linux 和 Mac OS X.你可以通过终端窗口输入 "python" 命令来查看本地是否已经安装Python以及Py ...
- 视图解析器InternalResourceViewResolver在什么情况下需要配置?在什么情况下不需要配置?
如果路径名是逻辑名的话,必须配置 -------------- 相对路径,即逻辑名称如果路径名是真实名的话,可选配置 若是绝对路径,则不用配置,即真实名称 注:试一下逻辑名和真实名的例子*****有用 ...
- bash、dash(/bin/bash和/bin/sh)的区别
Linux中的shell有多种类型,其中最常用的几种是Bourne shell(sh).C shell(csh)和Korn shell(ksh).三种shell各有优缺点. Bourne ...
- 392 Is Subsequence 判断子序列
给定字符串 s 和 t ,判断 s 是否为 t 的子序列.你可以认为 s 和 t 中仅包含英文小写字母.字符串 t 可能会很长(长度 ~= 500,000),而 s 是个短字符串(长度 <=10 ...
- 微信小程序一些常见的坑
1.小程序都报wxss编译错误 解决方法: 在控制台输入openVendor() ,清除里面的wcsc wcsc.exe 然后重启工具 2.微信小程序wx:for警告 Now you can prov ...