# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
233612 | triple_fault | Stove (JOI18_stove) | C++14 | 30 ms | 3192 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.
/* fucking change this 2020 */
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <set>
#include <map>
#include <random>
#define ll long long
using namespace std;
int main(void) {
ll n, k; scanf("%lld %lld", &n, &k);
ll vals[n];
for (ll i = 0; i < n; ++i) scanf("%lld", &vals[i]);
vector<ll> dif;
for (ll i = 1; i < n; ++i) dif.push_back(vals[i] - vals[i - 1] - 1);
ll ans = n;
sort(dif.begin(), dif.end());
for (ll i = 0; i < (n - k); ++i) ans += dif[i];
printf("%lld\n", 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... |