【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子列的个数; 然后让你输出 ...
随机推荐
- Vue.js实战 5.5章 购物车
<!DOCTYPE html> <html lang="en"> <head> <title>购物车示例</title> ...
- [App Store Connect帮助]六、测试 Beta 版本(3.3)管理测试员:查看测试员信息
如果您使用“TestFlight Beta 版测试”,您可以查看关于测试员的信息,并衡量测试员的参与度. 必要职能:“帐户持有人”职能.“管理”职能.“App 管理”职能.“开发者”职能或“营销”职能 ...
- Linux day01(一) 创建Linux虚拟机,设置虚拟机默认属性,虚拟机和Xhell建立连接
一:创建Linux虚拟机步骤: 1. 二:设置虚拟机默认属性 三:虚拟机和Xhell建立连接
- C语言小项目-基于TCP协议和SOCKET编程的网络通信系统
1.1 功能结构图 网络通信系统一共由4个模块组成,分别是点对点客户端.点对点服务端.服务器中转服务端.服务器中转客户端.这4个模块是成对使用的,点对点客户端和点对点服务端一起使用,服务器中转服务 ...
- 数学 FZU 2074 Number of methods
题目传送门 /* 数学:假设取了第i个,有C(n-1)(i-1)种取法 则ans = sum (C(n-1)(i-1)) (1<i<=n) 即2^(n-1) */ #include < ...
- 贪心 UVA 11729 Commando War
题目传送门 /* 贪心:按照执行时间长的优先来排序 */ #include <cstdio> #include <algorithm> #include <iostrea ...
- C# 事件与委托(转载)
委托的定义 delegate 是 C# 中的一种类型,它实际上是一个能够持有对某个方法的引用的类.与其它的类不同,delegate 类能够拥有一个方法的签名(signature),并且它"只 ...
- 389 Find the Difference 找不同
给定两个字符串 s 和 t,它们只包含小写字母.字符串 t 由字符串 s 随机重排,然后在随机位置添加一个字母.请找出在 t 中被添加的字母.示例:输入:s = "abcd"t = ...
- 什么是2MSL以及TIME_WAIT的作用
TIME_WAIT主要是用来解决以下几个问题: 1)上面解释为什么主动关闭方需要进入TIME_WAIT状态中提到的: 主动关闭方需要进入TIME_WAIT以便能够重发丢掉的被动关闭方FIN包的ACK. ...
- LN : leetcode 263 Ugly Number
lc 263 Ugly Number lc 263 Ugly Number Write a program to check whether a given number is an ugly num ...