当前位置:网站首页>[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 ;
}
边栏推荐
- 深入探索编译插桩技术(四、ASM 探秘)
- Leetcode (547) - number of provinces
- Tencent cloud webshell experience
- [batch dos-cmd command - summary and summary] - view or modify file attributes (attrib), view and modify file association types (Assoc, ftype)
- Part 7: STM32 serial communication programming
- .class文件的字节码结构
- Informatics Orsay Ibn YBT 1172: find the factorial of n within 10000 | 1.6 14: find the factorial of n within 10000
- Slam d'attention: un slam visuel monoculaire appris de l'attention humaine
- Equals() and hashcode()
- 学习光线跟踪一样的自3D表征Ego3RT
猜你喜欢
Attention slam: a visual monocular slam that learns from human attention
[batch dos-cmd command - summary and summary] - string search, search, and filter commands (find, findstr), and the difference and discrimination between find and findstr
随时随地查看远程试验数据与记录——IPEhub2与IPEmotion APP
New feature of Oracle 19C: automatic DML redirection of ADG, enhanced read-write separation -- ADG_ REDIRECT_ DML
批量获取中国所有行政区域经边界纬度坐标(到县区级别)
pytorch之数据类型tensor
深度学习之线性代数
深度学习之数据处理
Service asynchronous communication
.class文件的字节码结构
随机推荐
Build your own website (17)
Dell Notebook Periodic Flash Screen Fault
Configuring the stub area of OSPF for Huawei devices
What is time
Levels - UE5中的暴雨效果
from .cv2 import * ImportError: libGL.so.1: cannot open shared object file: No such file or direc
C Primer Plus Chapter 14 (structure and other data forms)
【JokerのZYNQ7020】AXI_ EMC。
Attention SLAM:一種從人類注意中學習的視覺單目SLAM
随时随地查看远程试验数据与记录——IPEhub2与IPEmotion APP
动态规划思想《从入门到放弃》
第六篇,STM32脉冲宽度调制(PWM)编程
Mongodb client operation (mongorepository)
Js+svg love diffusion animation JS special effects
Leetcode(547)——省份数量
Distributed cache
How do novices get started and learn PostgreSQL?
【批处理DOS-CMD命令-汇总和小结】-字符串搜索、查找、筛选命令(find、findstr),Find和findstr的区别和辨析
新手如何入门学习PostgreSQL?
Trace tool for MySQL further implementation plan