# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
136252 | KLPP | Stove (JOI18_stove) | C++14 | 30 ms | 2900 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 int lld;
#define rep(i,a,b) for(int i=a;i<b;i++)
int main(){
int n,k;
scanf("%d %d",&n,&k);
lld arr[n];
rep(i,0,n){
scanf("%lld",&arr[i]);
}
lld ans=arr[n-1]+1-arr[0];
lld diff[n-1];
rep(i,0,n-1)diff[i]=arr[i+1]-arr[i]-1;
sort(diff,diff+(n-1));
reverse(diff,diff+(n-1));
rep(i,0,k-1){
ans-=diff[i];
}
printf("%lld\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... |