Submission #593274

#TimeUsernameProblemLanguageResultExecution timeMemory
593274daisy2Stove (JOI18_stove)C++14
100 / 100
44 ms2028 KiB
#include<iostream> #include<algorithm> using namespace std; long long n,k,in[100005],pr,a,r; int main() { cin>>n>>k;k--; cin>>pr; r-=(pr-1); for(int i=1;i<n;i++) { cin>>a; in[i-1]=a-pr-1; pr=a; } r+=pr; sort(in,in+n); for(int i=n-1;i>=n-k;i--) { r-=in[i]; } cout<<r<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...