# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
42089 | nonocut | Stove (JOI18_stove) | C++14 | 33 ms | 3116 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n,k;
int p[maxn];
int main() {
int i,x,y;
scanf("%d%d",&n,&k);
for(i=0;i<n;i++) {
scanf("%d",&x);
if(i) p[i] = x-y-1;
y = x;
}
sort(p,p+n);
int ans = n;
for(i=0;i<n-k+1;i++) ans += p[i];
printf("%d",ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |