cf 760B.Frodo and pillows
二分,判断条件就是最小情况(设当前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的更多相关文章
- Codeforces 760B Frodo and pillows
题目链接:http://codeforces.com/problemset/problem/760/B 题意:n个床位,m个枕头,第k个位置最多有多少个枕头,其中相邻之间的差<=1; 第k个位置 ...
- Codefroces 760 B. Frodo and pillows
B. Frodo and pillows time limit per test 1 second memory limit per test 256 megabytes input standard ...
- 【codeforces 760B】Frodo and pillows
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- Codeforces 760B:Frodo and pillows(二分)
http://codeforces.com/problemset/problem/760/B 题意:有n张床m个枕头,每张床可以有多个枕头,但是相邻的床的枕头数相差不能超过1,问第k张床最多能拥有的枕 ...
- CodeForces760B
B. Frodo and pillows time limit per test:1 second memory limit per test:256 megabytes input:standard ...
- 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 ...
- Codeforces Round #393 (Div. 2)
A. Petr and a calendar time limit per test:2 seconds memory limit per test:256 megabytes input:stand ...
- 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 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
随机推荐
- Model Validation 和测试Post参数
using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentM ...
- python内置函数二
issubclass(a,b) 判断a类是否属于b的子类 返回为布尔值 locals() 显示局部变量 max() 取最大值 min() 取最小值 zip() 拉链方法 ...
- redis配置文件中常用配置详解
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/suprezheng/article/de ...
- 二 SVN代码冲突的解决
问题: A和B都是最新的代码,A修改了代码提交了,B也修改了代码,但是B提交的时候出现冲突的问题. 解决方案:编辑冲突 解决冲突: 方法一:将文件里面冲突的描述去掉,重新提交 方法二:软件解决冲突
- FBV CBV
目录 CBV 和 FBV 介绍 路由绑定 urlpatterns = [ # 1)项目启动,将test函数地址绑定给/test/路由 # 2)请求/test/访问后台,后台就会调用绑定的test函数 ...
- 选择本地文件上传控件 input标签
当要通过控件来选择本地文件上传的时候的一种方式 <input type="file" id="input-file"/> 注意 type类型一定要是 ...
- 数十万PhpStudy用户被植入后门,快来检测你是否已沦为“肉鸡”!
北京时间9月20日,杭州公安发布<杭州警方通报打击涉网违法犯罪暨‘净网2019’专项行动战果>一文,文章曝光了国内知名PHP调试环境程序集成包“PhpStudy软件”遭到黑客篡改并植入“后 ...
- (转)如何判断VPS是基于哪种虚拟技术?Xen、OpenVZ、Xen HVM、KVM还是VMware
对于VPS新手来说,怕被无良的奸商给忽悠,下的Xen的却给的OpenVZ的,如何来判断自己买的VPS是那种虚拟技术的,下面VPS侦探整理一些常见的方法. 1.通过系统上的相关目录或文件判断 执行:ls ...
- 《新标准C++程序设计》4.4(C++学习笔记14)
运算符重载为友元函数 一般情况下,将运算符重载为类的成员函数,是较好的选择. 但有时,重载为成员函数不能满足使用要求,重载为普通函数,又不能访问类的私有成员,所以需要将运算符重载为友元. class ...
- ORACLE添加新用户并配置权限 添加其他用户的表权限
添加用户配置权限 1.查出表空间所在位置 ,file_name from dba_data_files order by file_id; 2.根据步骤1查出的路径.将路径替换掉并指定用户名 路径:D ...