# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
248832 | rocks03 | Stove (JOI18_stove) | C++14 | 25 ms | 2932 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 pii pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N, K; cin >> N >> K;
int a[N];
for(int i = 0; i < N; i++) cin >> a[i];
vector<ll> v;
for(int i = 1; i < N; i++) v.pb(a[i] - a[i-1] - 1);
sort(v.begin(), v.end(), greater<ll>());
ll ans = N;
for(int i = K-1; i < N-1; i++) ans += v[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... |