codeforces 493 C Vasya and Basketball
题意:给出三分线的值d,分别有两支队伍,如果小于等于d,得2分,如果大于d,得三分,问使得a-b最大时的a,b
一看到题目,就想当然的去二分了----啥都没分出来---55555555
后来才知道不能二分,因为随着d的增大,两个队的得分都会逐渐减少,但是两个队伍的得分的差值的单调性却不知道
是这一篇这样讲的 http://www.cnblogs.com/huangxf/p/4142760.html
然后就依次枚举d的值,维护一个最大值
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cmath>
#include<stack>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
using namespace std; typedef long long LL;
const int INF = (<<)-;
const int mod=;
const int maxn=; int n,m;
int a[maxn],b[maxn],c[maxn]; int main(){
int cnt=;
c[++cnt]=;
scanf("%d",&n);
for(int i=;i<n;i++) scanf("%d",&a[i]),c[++cnt]=a[i];
scanf("%d",&m);
for(int i=;i<m;i++) scanf("%d",&b[i]),c[++cnt]=b[i]; sort(a,a+n);
sort(b,b+m);
sort(c,c+cnt);
int tmp=-INF,L,R; int lb,ub;
for(int i=;i<=cnt;i++){
int x=upper_bound(a,a+n,c[i]) - a;
int y=upper_bound(b,b+m,c[i]) - b; lb = x* + (n-x)*;
ub = y* + (m-y)*;
if(lb - ub > tmp){
tmp=lb-ub;
L=lb;R=ub;
}
if(lb - ub == tmp && lb > L) L = lb;
}
printf("%d:%d\n",L,R);
return ;
}
codeforces 493 C Vasya and Basketball的更多相关文章
- 【Codeforces 493C】Vasya and Basketball
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 枚举三分线(离散后)的位置 然后根据预处理的前缀和,快速算出两个队伍的分数. [代码] #include <bits/stdc++.h& ...
- codeforces 493 D Vasya and Chess【 博弈 】
题意:给出n*n的棋盘,白方在(1,1),黑方在(1,n)处,每一步可以上下左右对角线走,哪个先抓到另一个,则它获胜 可以画一下,发现n是奇数的时候,白方先走,无论它怎么走,黑方和它走对称的,黑方都一 ...
- Codeforces 493C - Vasya and Basketball
C. Vasya and Basketball 题目链接:http://codeforces.com/problemset/problem/493/C time limit per test 2 se ...
- Codeforces Round #281 (Div. 2) C. Vasya and Basketball 二分
C. Vasya and Basketball time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- Codeforces Round #281 (Div. 2) C. Vasya and Basketball 暴力水题
C. Vasya and Basketball time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- Codeforces Round #281 (Div. 2) C. Vasya and Basketball 排序
C. Vasya and Basketball Vasya follows a basketball game and marks the distances from which each te ...
- cf493C Vasya and Basketball
C. Vasya and Basketball time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- Vasya and Basketball CodeForces - 493C
Vasya follows a basketball game and marks the distances from which each team makes a throw. He knows ...
- Codeforces 493 E.Devu and Birthday Celebration
\(>Codeforces \space 493\ E.Devu\ and\ Birthday\ Celebration<\) 题目大意 : 有 \(q\) 组询问,每次有 \(n\) 小 ...
随机推荐
- 在C#中运行PowerShell
C#中运行PowerShell需要用到System.Management.Automation.dll.在Visual Studio中可以通过NuGet添加引用,package名字为"Sys ...
- 错误:java.lang.IllegalStateException: TimerTask is scheduled already
Process: com.multak.cookaraclient, PID: 27384 java.lang.RuntimeException: Unable to resume activity ...
- web.xml中的url-pattern写法规则及匹配过程
servlet和filter在javaEE开发中很常用,因此有必要知道web.xml文件映射的规则 1. 写法 ①完全匹配:以“/”开头,以字母(非“*”)结束 如:<url-patte ...
- WinDebug使用
File->Symbol File Path-> SRV*C:\MyLocalSymbols*http://msdl.microsoft.com/download/symbols ...
- C++中关于文本内容的实用操作集合(新)(添加一些关于文件流的介绍)
首先先给大家一个链接:http://baike.baidu.com/view/1679747.htm 主要是关于ios的使用,头文件要include<ios>,然后就可以调用下面的一些操作 ...
- poj1050查找最大子矩阵和
题目: To the Max Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 48507 Accepted: 2566 ...
- luogu P4213 【模板】杜教筛(Sum)
Code: #include <bits/stdc++.h> #include <tr1/unordered_map> using namespace std; using n ...
- CF1041F Ray in the tube构造_思维
不难发现起点必定是一个点. 每次间隔的距离一定是 2k2^k2k,关键就是要判断两点是否在同一跳跃距离上可被同时覆盖. 我们可以对上边进行 x1≡x_{1}\equivx1≡ x2mod(2∗dx) ...
- 转载一遍比较好的,django2.1搭建博客教程
非常感谢这位博主,找了几个星期终于找到了 https://www.dusaiphoto.com/article/article-detail/4/
- 新手学python-Day4-进制,数据类型,编码转换,列表
python3中字符串的编码转换 names=b'\xe2\x82\xac20'.decode('utf-8') print(names) names='€20'.encode('utf-8') pr ...