# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
203525 | SoGood | Stove (JOI18_stove) | C++14 | 79 ms | 2392 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;
using ll = long long;
#define int ll
const int N = 1e5 + 11;
int n, k, a[N];
main() {
cin>>n>>k;
for (int i=1;i<=n;++i) cin>>a[i];
vector<int> v;
for (int i = 2; i <= n; ++i) v.push_back(a[i]-a[i-1]-1);
sort(v.begin(), v.end(),greater<int>());
int ans=0;
--k;
for (int i = k; i < v.size(); ++i) ans+=v[i];
cout<<ans+n;
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... |