# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
731107 | sleepntsheep | Stove (JOI18_stove) | C++17 | 30 ms | 1700 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;
int main()
{
int n, k; long long z = 0;
scanf("%d%d", &n, &k);
auto t = new int[n];
for (int i = 0; i < n; i++) scanf("%d", t+i);
sort(t, t+n); z = t[n-1] - t[0] + 1;
for (int i = 1; i < n; i++) t[i-1] = t[i] - t[i-1];
sort(t, t+n-1, greater<int>());
for (int i = 0; i < k - 1; i++) z -= t[i] - 1;
printf("%lld", z);
delete []t;
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... |