#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
int n,k;
ll t;
ll x[100001];
pair<ll,int>st[100001];
bool got[100001];
bool solve(ll s){
ll blood=s;
int l=k,r=k;
for(int i=1; i<n ;i++) got[i]=false;
for(int i=1; i<n ;i++){
got[st[i].se]=true;
while(got[l-1]){
l--;
blood-=x[l+1]-x[l];
if(blood<0) return false;
blood+=s;
}
while(got[r]){
blood-=x[r+1]-x[r];
if(blood<0) return false;
blood+=s;
r++;
}
}
return true;
}
int main(){
ios::sync_with_stdio(false);
cin >> n >> k >> t;
for(int i=1; i<=n ;i++){
cin >> x[i];
}
for(int i=1; i<n ;i++){
st[i]={x[i+1]-x[i],i};
}
sort(st+1,st+n);
ll l=0,r=1e9/t+1;
while(l!=r){
ll mid=(l+r)/2;
if(solve(mid*t*2)) r=mid;
else l=mid+1;
}
cout << l << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |