# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
204066 | Kastanda | Stove (JOI18_stove) | C++11 | 65 ms | 6396 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.
// In The Name Of The Queen
#include<bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, k, tot, A[N];
int main()
{
scanf("%d%d", &n, &k);
for (int i = 1; i <= n; i ++)
scanf("%d", &A[i]);
tot += n;
multiset < int > ST;
for (int i = 1; i < n; i ++)
ST.insert(A[i + 1] - A[i] - 1);
for (int i = 1; i <= n - k; i ++)
{
int a = * ST.begin();
ST.erase(ST.begin());
tot += a;
}
return !printf("%d\n", tot);
}
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... |