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\) 小 ...
随机推荐
- Broadcast Receiver广播接收器
1.概述 广播接收器不仅能接受来自系统的内容,也可以接受来自其他app的内容.广播分为标准广播和有序广播. 2.标准广播 一种完全异步执行的广播,在广播发出之后几乎所有的广播接收器都在同一时刻接受到广 ...
- .net 三大核心对象
.net 三大核心对象 HttpRequest 现在总算轮到第一个核心对象出场了.MSDN给它作了一个简短的解释:“使 ASP.NET 能够读取客户端在 Web 请求期间发送的 HTTP 值.”这个解 ...
- c++标准库都有哪些文件
from:http://topic.csdn.net/u/20090201/16/3bd41b72-5694-474e-a68b-98b2f070e76b.html C++标准库的所有头文件都没有扩展 ...
- socket代码(简单)
SERVER: #!/usr/bin/python # -*- coding: utf-8 -*- import socket import time s = socket.socket(socket ...
- jquery获取自定义属性的值
//获取属性值 1 <div id="text" value="黑哒哒的盟友"><div> jQuery取值: $("#tex ...
- Pyhton学习——Day47
# 转载:http://www.cnblogs.com/yuanchenqi/articles/6357507.html# 外键:一种约束条件,与主键对应# 主表:被绑定的表:字表# 外键约束:# - ...
- Pyhton学习——Day26
#多态:多态指的是一类事物有多种形态# import abc# class Animal(metaclass = abc.ABCMeta):# 同一类事物:动物# @abc.abstractclass ...
- 电子邮件的三个协议: SMTP、IMAP、POP3
个人总结: 读完这篇文章需要10分钟 讲解了跟电子邮件有关的三个协议: SMTP(simple message transfer protocol 简单信息传输协议 IMAP (internet me ...
- js数组的一些骚操作 (用一行代码实现)
1.扁平化n维数组 1.终极篇 [1,[2,3]].flat(2) //[1,2,3] [1,[2,3,[4,5]].flat(3) //[1,2,3,4,5] [1[2,3,[4,5[...]].f ...
- 【洛谷4941】War2 状压Dp
简单的状压DP,和NOIP2017 Day2 找宝藏 代码几乎一样.(比那个稍微简单一点) f[i][j] ,i代表点的状态,j是当前选择的点,枚举上一个选到的点k 然后从f[i-(1<< ...