# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
45125 | Pajaraja | Stove (JOI18_stove) | C++17 | 36 ms | 10404 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>
int t[100007],a[100007];
int main()
{
int n,k;
scanf("%d%d",&n,&k);
for(int i=0;i<n;i++) scanf("%d",&t[i]);
int al=t[n-1]+1-t[0];
for(int i=0;i<n-1;i++) a[i]=t[i+1]-t[i]-1;
std::sort(a,a+n-1,std::greater<int>() );
for(int i=0;i<k-1;i++) al-=a[i];
printf("%d",al);
}
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... |