# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
219624 | MKopchev | Stove (JOI18_stove) | C++14 | 36 ms | 2088 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 nmax=1e5+42;
int n,k,inp[nmax];
int help[nmax];
int main()
{
scanf("%i%i",&n,&k);
for(int i=1;i<=n;i++)scanf("%i",&inp[i]);
k--;
int ret=inp[n]+1-inp[1];
for(int i=1;i<n;i++)help[i]=inp[i+1]-(inp[i]+1);
sort(help+1,help+n+1);
for(int i=n;i>=n-k+1;i--)ret=ret-help[i];
printf("%i\n",ret);
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... |