Submission #128623

#TimeUsernameProblemLanguageResultExecution timeMemory
128623jangwonyoungSparklers (JOI17_sparklers)C++14
0 / 100
2 ms376 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...