| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 106039 | he_____he | Stove (JOI18_stove) | C++14 | 22 ms | 2944 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;
typedef long long ll;
int readint(){
int x=0,f=1; char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int n,k;
ll a[100005],b[100005];
int main(){
n=readint(); k=readint()-1;
for(int i=1;i<=n;i++) a[i]=readint();
for(int i=1;i<=n-1;i++) b[i]=a[i+1]-a[i]-1;
sort(b+1,b+n);
ll sum=a[n]-a[1]+1;
for(int i=n-1;i>=n-k;i--) sum-=b[i];
printf("%lld\n",sum);
return 0;
}| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
