二分,判断条件就是最小情况(设当前k位取x)比剩余值(m-x)要小。(貌似又做麻烦了2333)

 #include<bits/stdc++.h>
#define LL long long
#define N 100005
using namespace std;
inline int ra()
{
int x=,f=; char ch=getchar();
while (ch<'' || ch>'') {if (ch=='-') f=-; ch=getchar();}
while (ch>='' && ch<='') {x=x*+ch-''; ch=getchar();}
return x*f;
}
int n,m,k;
bool check(LL x)
{
if (x==) return m>=n;
LL mx1=(k-)*(x++x+k-)>>,mn1;
LL mx2=(n-k)*(x++x+n-k)>>,mn2;
if (x>=k) mn1=(k-)*(x+x-k)>>;
else mn1=((x-)*(x)>>)+(k-x);
if (x>=n-k) mn2=(n-k)*(x-+x-n+k)>>;
else mn2=((x-)*(x)>>)+(n-k-x+);
if (mn1+mn2>m-x) return ;
return ;
}
int main()
{
n=ra(); m=ra(); k=ra();
int l=,r=m;
// check(3); while (1);
while (l<r)
{
int mid=l+r>>;
if (check(mid)) l=mid+;
else r=mid;
}
if (check(l)) cout<<l; else cout<<l-;
return ;
}

cf 760B.Frodo and pillows的更多相关文章

  1. Codeforces 760B Frodo and pillows

    题目链接:http://codeforces.com/problemset/problem/760/B 题意:n个床位,m个枕头,第k个位置最多有多少个枕头,其中相邻之间的差<=1; 第k个位置 ...

  2. Codefroces 760 B. Frodo and pillows

    B. Frodo and pillows time limit per test 1 second memory limit per test 256 megabytes input standard ...

  3. 【codeforces 760B】Frodo and pillows

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  4. Codeforces 760B:Frodo and pillows(二分)

    http://codeforces.com/problemset/problem/760/B 题意:有n张床m个枕头,每张床可以有多个枕头,但是相邻的床的枕头数相差不能超过1,问第k张床最多能拥有的枕 ...

  5. CodeForces760B

    B. Frodo and pillows time limit per test:1 second memory limit per test:256 megabytes input:standard ...

  6. Codeforces Round #393 (Div. 2) (8VC Venture Cup 2017 - Final Round Div. 2 Edition)A 水 B 二分 C并查集

    A. Petr and a calendar time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  7. Codeforces Round #393 (Div. 2)

    A. Petr and a calendar time limit per test:2 seconds memory limit per test:256 megabytes input:stand ...

  8. ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'

    凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...

  9. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

随机推荐

  1. django 自定义模版过滤器

    自定义的模版过滤器必须要放在app中,并且该app必须在INSTALLED_APPS中进行安装.然后再在这个app下面创建一个python包叫做templatetags(这个名字是固定的,不能随意更改 ...

  2. Navicat导入json文件到数据库

    最近做小程序商城系统,物流管理这块需要存储国际和中国的物流地址. 所以,天哪,地址那么的多!!!! www.baidu.com,搜索大佬是如何做的.有的是通过访问阿里云快递物流api接口获取数据存入数 ...

  3. Java项目xml相关配置

    一.web.xml //设置会话过期时间,这里单位是分钟 <session-config> <session-timeout>30</session-timeout> ...

  4. MySQL存储过程例子

    -- 索引 INDEXCREATE INDEX idx_sname ON student( sname(4)); ALTER TABLE teacher add index idx_tname(tna ...

  5. docker-jenkins SSH Publishers时踩的坑

    source相对路径问题,不是 /var/jenkins_home/workspace/build-renren/target/renren-fast.war  或环境变量,而是  target/re ...

  6. P1079 延迟的回文数

    P1079 延迟的回文数 转跳点:

  7. package报错

    java类的第一行package 包路径 package报错 jdk版本不一致 或者jar包冲突

  8. 零距离初体验uboot

    一.uboot配置编译步骤 1.开发板光盘的BSP 2.复制到虚拟机,tar -jxvf qt_x210v3_130807.tar.bz2 3.配置:make x210_sd_config 4.出现C ...

  9. vDom和domDiff

    虚拟dom和domDiff 1. 构建虚拟DOM var tree = el('div', {'id': 'container'}, [ el('h1', {style: 'color: blue'} ...

  10. 3-安装RabbitMQ

    1. 安装erlang 1.1 下载erlang http://www.erlang.org/downloads/20.1 yum -y install make ncurses-devel gcc  ...