Submission #1106059

#TimeUsernameProblemLanguageResultExecution timeMemory
1106059lufychopStove (JOI18_stove)C++14
0 / 100
1 ms336 KiB
#include <bits/stdc++.h> using namespace std; int main(void) { int n,k,ans=1; cin>>n>>k; int t[n],a[n]; for(int i=0;i<n;i++) { cin>>t[i]; } a[0]=1; for(int i=1;i<n;i++) { a[i]=t[i]-t[i-1]-1; ans=ans+a[i]; } sort(a,a+n); for(int i=n-1;i>=n-k;i--) { ans=ans-a[i]; } cout<<ans+n; return 0; } /* 3 3 1 3 6 1 1 3 2 6 3 10 5 1 2 5 6 8 11 13 15 16 20 1 1 1->3 2 1 5 3 5->9 6 1 8 2 11 3 11->14 13 2 15 2 15->17 16 1 20 4 20->21 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...