# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1033570 | BuiDucManh123 | Stove (JOI18_stove) | C++14 | 15 ms | 2028 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>
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define taskname ""
using namespace std;
ll n,k,i,b[100009],a[100009],ans;
int main() {
if (fopen(taskname".inp","r")) {
freopen(taskname".inp","r",stdin);
freopen(taskname".out","w",stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>k;
for(i=1;i<=n;i++) cin>>a[i];
for(i=1;i<n;i++){
b[i]=a[i+1]-a[i]-1;
}sort(b+1,b+n,greater<>());
ans=0;
for(i=1;i<k;i++)
ans+=b[i];
cout<<a[n]-a[1]+1-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... |