이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
if(s>2e9) while(true);
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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |