# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
334195 | shahriarkhan | Stove (JOI18_stove) | C++14 | 25 ms | 2408 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 INF = 1e9 ;
int main()
{
int n , k ;
scanf("%d%d",&n,&k) ;
int a[n+1] ;
for(int i = 1 ; i <= n ; ++i) scanf("%d",&a[i]) ;
sort(a+1,a+n+1) ;
vector<int> v ;
int tot = a[n] - a[1] + 1 ;
for(int i = 1 ; i < n ; ++i)
{
v.push_back(a[i]-a[i+1]+1) ;
}
sort(v.begin(),v.end()) ;
for(int i = 0 ; i < (k-1) ; ++i) tot += v[i] ;
printf("%d\n",tot) ;
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... |