当前位置:网站首页>[noip2015] jumping stone
[noip2015] jumping stone
2022-07-01 18:23:00 【cq. tiancx】
subject : [NOIP2015] Rock jumping , ha-ha , Let's look at a question with two answers today , This is from NOIP A question on , Okay , Let's have a look at the meaning of the title :
The title description is copied , There may be some display errors , I'll put the title link below !
Topic link : [NOIP2015] Rock jumping
Title Description
annual “ Rock jumping ” The game is about to start again ! The competition will be held in a straight river , There are some huge rocks in the river . The organizing committee has selected two rocks as the starting and ending points of the competition . Between the beginning and the end , Yes N A rock ( Rock without start and end ). In the course of the game , The players will start from the starting point , Each step jumps to the adjacent rock , Until we reach the end . In order to improve the difficulty of the competition , The organizing committee plans to remove some rocks , Make the shortest jumping distance of players in the competition as long as possible . Due to budget constraints , At most, the organizing committee will move from the starting point to the end point M A rock ( You can't remove the rocks at the beginning and the end ).Input description
The first line of the input file contains three integers L,N,M, The distance from the starting point to the ending point , The number of rocks between the beginning and the end , And the maximum number of rocks removed by the Organizing Committee .
Next N That's ok , One integer per row , The first i The whole number of lines Di(0 < Di < L) It means the first one i The distance between the rock and the starting point . These rocks are given in the order of small to large distance from the starting point , And there won't be two rocks in the same place .
Output description
The output file contains only one integer , That is, the maximum value of the shortest jump distance .
Example 1
Input
25 5 2
2
11
14
17
21
Output
4
Ideas :
This question can be done in the way of two-point answer ! Specifically, let's look directly at the code , Annotated amount !
Let's look at success AC The code of :
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int l,n,m;
int a[100010];
int check(int x){
int t=0;//t Indicates the position of the last stone
int cnt=0;// Record the number of stones that have been removed
for(int i=1;i<=n+1;i++){
if(a[i]-t<x){
// Need to move this stone
if(++cnt>m) return 0;// If the number of stones to be removed is greater than m, Then the scheme is not feasible
}else t=a[i];
}
return 1;
}
int main(){
ios::sync_with_stdio(false);
cin>>l>>n>>m;
for(int i=1;i<=n;i++) cin>>a[i];
a[n+1]=l;
int l1=0,r1=l;
while(l1<r1){
int mid=(l1+r1+1)>>1;
if(check(mid)) l1=mid;
else r1=mid-1;
}
cout<<l1;
return 0;
}
Thanks for reading , Because the author level is limited , There are inevitably shortcomings , If the reader finds a problem , Please criticize , Leave a message in the message area or send a private message to inform , I will revise it as soon as possible . If you guys have any good solutions , Or meaningful solutions can be displayed in the comment area , Thank you very much .
Writing is not easy to , I hope all bosses will praise me , Add a focus on !
边栏推荐
- Kia recalls some K3 new energy with potential safety hazards
- Android development interview was badly hit in 3 years, and now the recruitment technical requirements are so high?
- Domestic spot silver should be understood
- Debiasing word embeddings | talking about word embedding and deviation removal # yyds dry goods inventory #
- Cloud picture says | distributed transaction management DTM: the little helper behind "buy buy buy"
- Leetcode problem solving series -- continuous positive sequence with sum as s (sliding window)
- ISO 27001 Information Security Management System Certification
- Bug of QQ browser article comment: the commentator is wrong
- MES production equipment manufacturing execution system software
- 开发那些事儿:EasyCVR平台添加播放地址鉴权
猜你喜欢

Highly reliable program storage and startup control system based on anti fuse FPGA and QSPI flash

Classpath classpath

Yuancosmos game farmersworld farmers world - core content of the second conference in China!
![[C supplement] [string] display the schedule of a month by date](/img/9c/5fcc6bfc8fe0f433c0d1eba92b5c3e.jpg)
[C supplement] [string] display the schedule of a month by date

Kernel stray cat stray dog pet adoption platform H5 source code

PTA year of birth

Mysql database design
![Htt [ripro network disk link detection plug-in] currently supports four common network disks](/img/e4/c06b94243cdbe391b8b2124ff30789.jpg)
Htt [ripro network disk link detection plug-in] currently supports four common network disks

Extract the compressed package file and retrieve the password

【Try to Hack】vulnhub DC4
随机推荐
Is the fund of futures account safe? How to open an account?
Key points on February 15, 2022
APK签名流程介绍[通俗易懂]
Leetcode problem solving series -- continuous positive sequence with sum as s (sliding window)
股票万1免5证券开户是合理安全的吗,怎么讲
On the language internationalization of Yongzhong Office
Source code of new campus errand / campus task platform on mutual station
Smart factory digital management system software platform
Work and leisure suggestions of old programmers
Leetcode 1380. Lucky numbers in the matrix (save the minimum number of each row and the maximum number of each column)
This is the latest opportunity of the London bank trend
L'ouverture d'un compte d'actions en ligne est - elle sécurisée? Fiable?
MFC obtains local IP (used more in network communication)
Quick foundation of group theory (5): generators, Kelley graphs, orbits, cyclic graphs, and "dimensions" of groups?
New patent applications and transfers
Nielseniq found that 60% of the re launched products had poor returns
Cloud picture says | distributed transaction management DTM: the little helper behind "buy buy buy"
Session layer of csframework, server and client (1)
徽商期货是正规期货平台吗?在徽商期货开户安全吗?
Talk about the favorite tools used by project managers