# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
127206 | hungcung | Stove (JOI18_stove) | C++14 | 27 ms | 1144 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;
int n,k,a[100005],res[100005],dem,ans;
int main(){
scanf("%d %d",&n,&k);
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
if(i>=1){
res[dem]=a[i]-a[i-1];
dem++;
}
}
sort(res,res+dem);
ans=k;
for(int i=0;i<n-k;i++){
ans+=res[i];
}
printf("%d",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... |