当前位置:网站首页>[Niuke] [noip2015] jumping stone
[Niuke] [noip2015] jumping stone
2022-07-07 01:05:00 【*DDL_ GzmBlog】
Preface
t a g : tag : tag: Two points
Two points answer
The question :
Ideas :
Because what the title asks is Shortest maximum , A very standard two-point inquiry method
So we can consider Two point shortest distance , So how do we check Well
It's simple , Obviously, what needs to be judged now x, If the difference between two stones is less than x When , We must remove it
So we just need to judge the quantity and m The relationship between
Of course, we can move the state through last To transfer
code :
int L,n,m;
int a[N];
int i,j;
int b[N];
bool check(int x){
int cnt = 0;
int last = 0 ;
Fup(i,1,n+1){
if(a[i] - last < x) cnt++;
else last = a[i];
if(cnt > m) return false;
}
return true;
}
void solve(){
// cin>>L>>N>>M;
cin>>L>>n>>m;
Fup(i,1,n) cin>>a[i];
a[n+1] = L;
int l = 0 , r = L;
//cout<<ans<<endl;
while(l<=r){
int mid = (l+r)>>1;
if(check(mid)){
l = mid+1;
}
else r = mid - 1;
}
cout<<((l+r)>>1)<<endl;
}
signed main(){
//int t;cin>>t;while(t--)
solve();
return 0 ;
}
边栏推荐
- 筑梦数字时代,城链科技战略峰会西安站顺利落幕
- SuperSocket 1.6 创建一个简易的报文长度在头部的Socket服务器
- Rainstorm effect in levels - ue5
- [force buckle]41 Missing first positive number
- .class文件的字节码结构
- Configuring OSPF basic functions for Huawei devices
- Attention slam: a visual monocular slam that learns from human attention
- Distributed cache
- Zynq transplant ucosiii
- Js+svg love diffusion animation JS special effects
猜你喜欢
《安富莱嵌入式周报》第272期:2022.06.27--2022.07.03
[C language] dynamic address book
Dell笔记本周期性闪屏故障
[Batch dos - cmd Command - Summary and Summary] - String search, find, Filter Commands (FIND, findstr), differentiation and Analysis of Find and findstr
Deep understanding of distributed cache design
Telerik UI 2022 R2 SP1 Retail-Not Crack
[software reverse - solve flag] memory acquisition, inverse transformation operation, linear transformation, constraint solving
ESP Arduino (IV) PWM waveform control output
Chapter II proxy and cookies of urllib Library
[yolov5 6.0 | 6.1 deploy tensorrt to torch serve] environment construction | model transformation | engine model deployment (detailed packet file writing method)
随机推荐
《安富莱嵌入式周报》第272期:2022.06.27--2022.07.03
.class文件的字节码结构
. Bytecode structure of class file
Informatics Olympiad YBT 1171: factors of large integers | 1.6 13: factors of large integers
浅谈测试开发怎么入门,如何提升?
ESP Arduino (IV) PWM waveform control output
"Exquisite store manager" youth entrepreneurship incubation camp - the first phase of Shunde market has been successfully completed!
Service asynchronous communication
第六篇,STM32脉冲宽度调制(PWM)编程
Informatics Orsay Ibn YBT 1172: find the factorial of n within 10000 | 1.6 14: find the factorial of n within 10000
Advantages and disadvantages of code cloning
How to get started and improve test development?
Deep understanding of distributed cache design
pyflink的安装和测试
Chapter II proxy and cookies of urllib Library
Telerik UI 2022 R2 SP1 Retail-Not Crack
省市区三级坐标边界数据csv转JSON
资产安全问题或制约加密行业发展 风控+合规成为平台破局关键
Dell笔记本周期性闪屏故障
Learning notes 5: ram and ROM