前些年的很多题也是,来不及写全了,过两天有空再补
1.NOIP2015d2t1 跳石头
原题:https://vijos.org/p/1981
其实考试之前我连这题题解好像都看过,但考场上愣是啥也不会还贪心来着......从前我都是什么状态......
二分答案(最短跳跃距离的最大值),判断的时候直接用这个值去模拟跳跃,小于这个距离的石头都挪掉,看看挪掉的石头有没有超过m个
#include <cstdio>
#include <cstring>
const int N=50500;
int a[N],L,n,m,ans;
bool judge(int k){
for(int i=0,top=0,j=1;i<=n;i=j,j=i+1)
while(a[j]-a[i]<k){
top++,j++;
if(top>m) return false;
}
return true;
}
int main(){
freopen("stone.in","r",stdin);
freopen("stone.out","w",stdout);
scanf(