题意:给出三分线的值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的更多相关文章

  1. 【Codeforces 493C】Vasya and Basketball

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 枚举三分线(离散后)的位置 然后根据预处理的前缀和,快速算出两个队伍的分数. [代码] #include <bits/stdc++.h& ...

  2. codeforces 493 D Vasya and Chess【 博弈 】

    题意:给出n*n的棋盘,白方在(1,1),黑方在(1,n)处,每一步可以上下左右对角线走,哪个先抓到另一个,则它获胜 可以画一下,发现n是奇数的时候,白方先走,无论它怎么走,黑方和它走对称的,黑方都一 ...

  3. Codeforces 493C - Vasya and Basketball

    C. Vasya and Basketball 题目链接:http://codeforces.com/problemset/problem/493/C time limit per test 2 se ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. cf493C Vasya and Basketball

    C. Vasya and Basketball time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  8. Vasya and Basketball CodeForces - 493C

    Vasya follows a basketball game and marks the distances from which each team makes a throw. He knows ...

  9. Codeforces 493 E.Devu and Birthday Celebration

    \(>Codeforces \space 493\ E.Devu\ and\ Birthday\ Celebration<\) 题目大意 : 有 \(q\) 组询问,每次有 \(n\) 小 ...

随机推荐

  1. php链接memcache操作

    设置值 set key 压缩标识 有效期 长度 set name 0 60 5 hello 压缩标识:用于告诉memcached服务器是否压所后存储数据,目的是为了节省磁盘空间,压所和解压缩会消耗时间 ...

  2. Chrome 开发工具系列

  3. 浅谈SpringCloud (二) Eureka服务发现组件

    上面学习到了如何由一个程序访问另一个程序,那么如果使用SpringCloud来进行访问,该如何访问呐? 可以借助Eureka服务发现组件进行访问. 可以借助官方文档:https://spring.io ...

  4. P2216 [HAOI2007]理想的正方形(二维RMQ)

    题目描述 有一个a*b的整数组成的矩阵,现请你从中找出一个n*n的正方形区域,使得该区域所有数中的最大值和最小值的差最小. 输入输出格式 输入格式: 第一行为3个整数,分别表示a,b,n的值 第二行至 ...

  5. js获取浏览器中相关容器的高度

    网页可见区域宽: document.body.clientWidth 网页可见区域高: document.body.clientHeight 网页可见区域宽: document.body.offset ...

  6. android webview一些注意事项(持续更新)

    1.loadUrl() 的参数必须“http://”开头: 2.如果用到内部类获取页面内容,此类不能混淆: 3.2中情况保持不混淆需要将webview所在的包都保持不混淆,常规的保持类不混淆不生效: ...

  7. ddk安装失败后的处理

    7600.16385.1版本的DDK,在xp的本上死活按不上,怎么办呢?自己就把其他机器上安装的DDK目录,拷贝过来. 怎么建编译环境呢? 查看x86 Checked Build Environmen ...

  8. 性能优化实战-join与where条件执行顺序

    昨天经历了一场非常痛苦的性能调优过程,但是收获也是刻骨铭心的,感觉对sql引擎的原理有了进一步认识. 问题起源于测试人员测一个多条件检索的性能时,发现按某个条件查询会特别慢.对应的sql语句简化为: ...

  9. C++面向对象的设计思想——小结

    1 对象的概念 面向对象(Object Oriented Analysis Design,OOAD)的思想把整个世界看成是由具有某种特征行为功能的基本单元——对象构成的.OOAD把一个对象的特征称为属 ...

  10. ___Manacher(线性回文子串处理算法)

    昨晚的bc做得好忧郁----- 第一题改了好久好久好久----等改完发现比赛已经结束了(发现是枚举子集的位运算那儿写错了--) 第二题是判断能否将一个字符串划分成三段回文串 今天学了一点点  Mana ...