# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
146927 | GodTe | Stove (JOI18_stove) | C++14 | 29 ms | 1524 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;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
// #define TT() printf("%.4f sec\n", (double) clock() / CLOCKS_PER_SEC )
#define Fi first
#define Se second
#define rep(i, n) for(ll i=0;i<n;i++)
#define repp(i, n) for(ll i=1;i<=n;i++)
#define INF 1987654321
#define IINF 987654321987654321
int n,k; vector<int> v,v1;
int main(){
scanf("%d%d",&n,&k);
repp(i,n){
int x; scanf("%d",&x); v.push_back(x);
}
int ans = v[n-1]-v[0]+1;
rep(i,n-1) v1.push_back(v[i+1]-v[i]-1);
sort(v1.begin(),v1.end(),greater<int>());
rep(i,min(n-1,k-1)) ans -= v1[i];
printf("%d\n",ans);
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... |