# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
992554 | voi | Stove (JOI18_stove) | C++17 | 18 ms | 2004 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;
const int ar = 2e5+2;
const ll mod = 1e9+7;
const int oo = 1e9;
int n, k, a[2];
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
#define task "stove"
if(fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
cin >> n >> k;
int bit = 0;
vector <int> v;
for(int i = 1; i <= n; ++i) {
cin >> a[bit];
if(i > 1)
v.push_back(a[bit] - a[bit ^ 1] - 1);
bit ^= 1;
}
sort(v.begin(), v.end());
int res = n;
for(int i = 0; i < n - k; ++i)
res += v[i];
cout << res;
}
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... |