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\) 小 ...
随机推荐
- 初探MVC路由
文章目录: 1.认识理解URL,以及简单的路由 2.特性路由.传统路由.区域路由 3.路由生成URL&&绑定到操作&&路由约束 1.认识理解URL,以及简单的路由 默 ...
- 基于vue项目的js工具方法汇总
以下是个人过去一年在vue项目的开发过程中经常会用到的一些公共方法,在此进行汇总,方便以后及有需要的朋友查看~ let util = {}; /** * @description 日期格式化 * @p ...
- node——request和response的常用对象
request(http.IncomingMessage)和response(http.ServerResponse)对象介绍 request:服务器解析用户提交的http请求报文,将结果解析到req ...
- js获取路径参数对象
/** * 获取页面路径参数值 */ function getParams(key) { var result = {}; var paramStr = encodeURI(window.docume ...
- CF1037E Trips (离线+图上构造)
题目大意:一共有n个人,每天早上会有两个人成为朋友,朋友关系不具有传递性,晚上,它们会组织旅游,如果一个人去旅游,那么他不少于$k$个朋友也要和他去旅游,求每天的最大旅游人数 一开始并没有想到反向建图 ...
- Rsync和Sersync(企业实时同步方案)
注:本文章依据参考文章中的信息资料结合自己的实践操作而成 一.实验环境介绍 系统版本:Cent OS 7.4 X64 内核版本:3.10.0-693.5.2.el7.x86_64 系统采用最小化安装, ...
- CMDB设计
CMDB(资产管理数据库) CMDB是所有运维工具的数据基础 CMDB包含的内容 用户管理,记录测试,开发,运维人员的用户表 业务线管理,需要记录业务的详情 项目管理,指定此项目用属于哪条业务线,以及 ...
- php $_SERVER['PHP_SELF']安全漏洞
REQUEST_URI 返回的是包括后面数据串的地址,如 index.php?str=1234 PHP_SELF 是 index.php ------------------------------- ...
- 兴趣爱好-QQ的本地共享
QQ这个本地共享简直了,不就实现了公网FTP的功能么?好方便啊,有啥文件共享给好友就直接放在本地就可以了,真好用
- Spring+mybatis+struts框架整合的配置具体解释
学了非常久的spring+mybatis+struts.一直都是单个的用他们,或者是两两组合用过,今天总算整合到一起了,配置起来有点麻烦.可是配置完一次之后.就轻松多了,那么框架整合配置具体解释例如以 ...