# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
528477 | georgerapeanu | Stove (JOI18_stove) | C++11 | 32 ms | 2276 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;
scanf("%d %d", &n, &k);
vector<int> v(n, 0);
sort(v.begin(), v.end());
for(auto &it:v){
scanf("%d", &it);
}
vector<int> stuff;
for(int i = 1;i < n;i++){
stuff.push_back(v[i] - v[i - 1] - 1);
}
int ans = v.back() - v[0] + 1;
sort(stuff.begin(), stuff.end());
reverse(stuff.begin(), stuff.end());
for(int i = 0;i < k - 1;i++){
ans -= max(0, stuff[i]);
}
printf("%d", 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... |