# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
507243 | amukkalir | Stove (JOI18_stove) | C++17 | 33 ms | 2140 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;
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<ll,ll>
#define se second
#define fi first
#define pb push_back
#define wek puts("wekwek")
#define wik puts("-------")
const int nax = 1e5;
int n, k;
int t[nax+5];
signed main () {
scanf("%d %d", &n, &k);
priority_queue<int,vector<int>,greater<int>> pq;
int ans = n;
for(int i=0; i<n; i++) {
scanf("%d", &t[i]);
if(i > 0) {
pq.push(t[i]-t[i-1]-1);
}
}
for(int i=0; i<n-k; i++) {
ans += pq.top();
pq.pop();
}
printf("%d", ans);
}
/*
*/
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... |