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连试试水的深浅..... ...
随机推荐
- 「USACO5.4」奶牛的电信Telecowmunication
传送门 Luogu 解题思路 题目要求的是最小割点集,考虑用最小割来做. 所有边容量为1,直接求最小割? 这样肯定会出错,比如这种情况: 从最左边的点到最右边的点的最小割为2,但是答案是1,只要破坏中 ...
- bootstrap上下左右条纹边框悬停表格的使用
懒得找地址:https://jingyan.baidu.com/album/0bc808fc3d88941bd585b94c.html?picindex=1
- mysql 单表索引优化
建表语句 CREATE TABLE IF NOT EXISTS `article` ( `id` INT(10) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMEN ...
- js左右选项移动
<!--网页代码--><div class="modal" id="modal-primary7"> <div class=&qu ...
- LINQ---查询语法和方法语法
namespace ConsoleApplication45 { class Program { static void Main(string[] args) { , , , , , , }; va ...
- MongoDB 监控指标
MongoDB uptime 启动时长 asserts.user 用户的断言数量 asserts.warning 警告的断言数量 connections.current 当前的连接数 大于 650co ...
- MySQL 批量更新、删除数据shell脚本
#!/bin/bash. ~/.bash_profilelog=/tmp/update_log_1_$(date +%F).logvstart=1step=100vstop=$((${vstart}+ ...
- 使用Ghidra分析phpStudy后门
一.工具和平台 主要工具: Kali Linux Ghidra 9.0.4 010Editor 9.0.2 样本环境: Windows7 phpStudy 20180211 二 .分析过程 先在 Wi ...
- 51nod 1765 谷歌的恐龙
一开始看到了期望吓半死..然后弱弱的写了一下式子.设∑是出去m项之后的和,∑' 是m项的和. E=(n/m)*(∑'/m)+(n/m)*((n-m)/n)*(∑'/m+∑/(n-m))+(n/m)*( ...
- Flutter Web环境搭建
接上篇Flutter Windows下AndroidStudio环境搭建 1.https://github.com/flutter/flutter_web 下载放到本地路径下 2.系统Path增加(根 ...