# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
678061 | hello_there_123 | Stove (JOI18_stove) | C++17 | 45 ms | 2216 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 int long long
main(){
int N,K;
cin>>N>>K;
int ans = 0;
int arr[N+3];
for(int i=0;i<N;i++){
cin>>arr[i];
}
ans = arr[N-1]-arr[0]+1;
vector<int>v;
for(int i=1;i<N;i++){
v.push_back(arr[i]-arr[i-1]-1);
}
sort(v.begin(),v.end(),greater<int>());
for(int i=0;i<K-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... |