# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
123090 | Hideo | Stove (JOI18_stove) | C++14 | 28 ms | 2284 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;
#define ll long long
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define vi vector < int >
#define vl vector < ll >
#define pi pair < int, ll >
#define pii pair < int, pi >
#define vii vector < pi >
const int N = 3e5 + 7;
const int INF = 1e9 + 7;
int a[N];
int n, k;
ll ans;
vi dif;
main(){
cin >> n >> k;
ans = n;
for (int i = 1; i <= n; i++){
scanf("%d", &a[i]);
if (i > 1)
dif.pb(a[i] - a[i - 1] - 1);
}
sort(dif.begin(), dif.end());
for (int i = 0; i < n - k; i++)
ans += dif[i];
cout << 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... |