# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
108776 | thebes | Stove (JOI18_stove) | C++14 | 36 ms | 2168 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;
const int MN = 1e5+5;
typedef long long ll;
ll arr[MN], n, i, x, y, k, ans, r;
int main(){
scanf("%lld%lld%lld",&n,&k,&x);
r = k; k = max(0LL, n-k);
for(i=2;i<=n;i++){
scanf("%lld",&y);
arr[i-1]=y-x; x=y;
}
sort(arr+1,arr+n,[](ll i,ll j){return i<j;});
for(i=1;i<=k;i++) ans += arr[i];
printf("%lld\n",ans+r);
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... |