# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
41599 | Abelyan | Stove (JOI18_stove) | C++14 | 35 ms | 1516 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.
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define mpr make_pair
#define pr pair<int,long long>
#define st string
#define vint vector<int>
#define vpr vector<pr>
#define fr first
#define sc second
#define add push_back
#define del pop_back
#define qdel pop
inline int scn() { int hg; scanf("%d",&hg); return hg; };
const int N=100006;
int a[N],b[N];
int main(){
ios_base::sync_with_stdio(false);
int n=scn();
int k=scn();
for (int i=0;i<n;i++){
a[i]=scn();
if (i>0){
b[i-1]=a[i]-a[i-1]-1;
}
}
sort(b,b+n-1);
int ans=n;
for (int i=0;i<n-k;i++){
ans+=b[i];
}
cout<<ans<<endl;
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... |