当前位置:网站首页>[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 ;
}
边栏推荐
- 学习使用代码生成美观的接口文档!!!
- Configuring OSPF basic functions for Huawei devices
- 深入探索编译插桩技术(四、ASM 探秘)
- 重上吹麻滩——段芝堂创始人翟立冬游记
- How do novices get started and learn PostgreSQL?
- Part 7: STM32 serial communication programming
- Distributed cache
- Summary of being a microservice R & D Engineer in the past year
- [user defined type] structure, union, enumeration
- Stm32f407 ------- SPI communication
猜你喜欢

Configuring the stub area of OSPF for Huawei devices

Attention slam: a visual monocular slam that learns from human attention

Chenglian premium products has completed the first step to enter the international capital market by taking shares in halber international

Part IV: STM32 interrupt control programming

Niuke cold training camp 6B (Freund has no green name level)

. Bytecode structure of class file

重上吹麻滩——段芝堂创始人翟立冬游记

New feature of Oracle 19C: automatic DML redirection of ADG, enhanced read-write separation -- ADG_ REDIRECT_ DML

Periodic flash screen failure of Dell notebook

界面控件DevExpress WinForms皮肤编辑器的这个补丁,你了解了吗?
随机推荐
A brief history of deep learning (II)
Chapter II proxy and cookies of urllib Library
Stm32f407 ------- DAC digital to analog conversion
Niuke cold training camp 6B (Freund has no green name level)
mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such
第七篇,STM32串口通信编程
Periodic flash screen failure of Dell notebook
批量获取中国所有行政区域经边界纬度坐标(到县区级别)
Part 7: STM32 serial communication programming
什么是时间
Attention slam: a visual monocular slam that learns from human attention
[yolov5 6.0 | 6.1 deploy tensorrt to torch serve] environment construction | model transformation | engine model deployment (detailed packet file writing method)
Tensorflow 1.14 specify GPU running settings
Part VI, STM32 pulse width modulation (PWM) programming
【JokerのZYNQ7020】AXI_EMC。
第六篇,STM32脉冲宽度调制(PWM)编程
Equals() and hashcode()
Attention SLAM:一種從人類注意中學習的視覺單目SLAM
5种不同的代码相似性检测,以及代码相似性检测的发展趋势
Openjudge noi 1.7 10: simple password