| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1292944 | dm10r7 | Stove (JOI18_stove) | C++20 | 15 ms | 2340 KiB |
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
int n, k;
scanf("%lld %lld", &n, &k);
vector<int> t(n);
for (int i = 0; i < n; i++) {
scanf("%lld", &t[i]);
}
int ans = t.back() - t[0] + 1;
vector<int> gap;
for (int i = 0; i < n - 1; i++) {
gap.push_back(t[i + 1] - t[i] - 1);
}
sort(gap.rbegin(), gap.rend());
for (int i = 0; i < k - 1 && i < (int)gap.size(); i++) {
ans -= gap[i];
}
printf("%lld\n", ans);
return 0;
}
/*
dm10r7
*/
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... | ||||
