# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
486852 | TypeYippie | Stove (JOI18_stove) | C++14 | 19 ms | 2036 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;
int main(){
int n, k, time[100005], interval[100005];
scanf("%d%d", &n, &k);
for(int i = 0; i < n; i++){
scanf("%d", time+i);
if(i > 0){
interval[i-1] = time[i]-time[i-1]-1;
}
}
sort(interval, interval+n-1, greater<int>());
int ans = time[n-1]-time[0]+1;
for(int i = 0; i < k-1; i++){
ans -= interval[i];
}
printf("%d\n", ans);
return 0;
}
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... |