# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
516300 | Jomnoi | Stove (JOI18_stove) | C++17 | 30 ms | 2352 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>
#define DEBUG 0
using namespace std;
const int N = 1e5 + 10;
int t[N];
int main() {
int n, k;
scanf(" %d %d", &n, &k);
for(int i = 1; i <= n; i++) {
scanf(" %d", &t[i]);
}
int ans = t[n] - t[1] + 1;
priority_queue <int> pq;
for(int i = 2; i <= n; i++) {
pq.emplace(t[i] - t[i - 1] - 1);
}
while(!pq.empty() and --k) {
ans -= pq.top();
pq.pop();
}
cout << 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... |