# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
524362 | reni | Stove (JOI18_stove) | C++17 | 21 ms | 2828 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 endl '\n'
using namespace std;
long long a[100003], r[100003];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n,k,i,brm,res=0;
cin>>n>>k;
for(i=0;i<n;i++)
{
cin>>a[i];
if(i!=0)r[i-1]=a[i]-a[i-1]-1;
}
sort(r,r+n-1);
res=a[n-1]-a[0]+1;
for(i=n-2;i>=n-k;i--)
{
res-=r[i];
}
cout<<res<<endl;
}
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... |