# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
391507 | giorgikob | Stove (JOI18_stove) | C++14 | 25 ms | 2380 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>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;
const int N = 4e5+5, mod = 3;
int n,k;
vector<int>v;
int A[N];
ll answer;
inline void test_case(){
cin >> n >> k;
for(int i = 1; i <= n; i++){
cin >> A[i];
}
for(int i = 1; i < n; i++){
v.pb(A[i+1]-A[i]-1);
}
sort(v.begin(),v.end());
for(int i = 0; i < n-k; i++){
answer += v[i];
}
cout << answer+n << endl;
}
main(){
ios::sync_with_stdio(0);
int T = 1;
//cin >> T;
while(T--){
test_case();
}
}
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... |