| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1150503 | eldorbek_008 | Stove (JOI18_stove) | C++17 | 42 ms | 5808 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
int32_t main() {
int n, k;
cin >> n >> k;
if (n == 1) {
cout << k;
return 0;
}
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int ans = a.back() - a[0] + 1;
multiset<int, greater<int>> diff;
for (int i = 1; i < n; i++) {
diff.insert(a[i] - a[i - 1] - 1);
}
auto it = diff.begin();
for (int i = 0; i < k - 1; i++) {
ans -= *(it++);
}
cout << ans;
return 0;
} | # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
