# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
99146 | rzbt | Stove (JOI18_stove) | C++14 | 67 ms | 2420 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 mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define MAXN 100005
typedef long long ll;
using namespace std;
int n,k;
int niz[MAXN];
vector<int> razmaci;
int main()
{
scanf("%d %d", &n, &k);
for(int i=1;i<=n;i++)
scanf("%d", niz+i);
sort(niz+1,niz+1+n);
for(int i=2;i<=n;i++){
razmaci.pb(niz[i]-niz[i-1]-1);
}
sort(all(razmaci),greater<int>());
int res=niz[n]-niz[1]+1;
for(int i=0;i<k-1;i++)res-=razmaci[i];
printf("%d",res);
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... |