# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
171147 | Nodir_Bobiev | Stove (JOI18_stove) | C++14 | 7 ms | 632 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 FILE
using namespace std;
int main(){
# ifdef FILE
freopen( "input.txt", "r", stdin );
freopen( "output.txt", "w", stdout );
# endif
ios_base::sync_with_stdio( false );
int n, k;
cin >> n >> k;
vector < int > times;
for( int i = 0; i < n;i ++ ){
int tt;
cin >> tt;
times.push_back( tt );
}
int ans = times.back()-times[0]+1;
vector < int > diff;
for( int i = 0; i < n-1; i ++ ){
diff.push_back( times[i+1]-times[i]-1 );
}
sort( diff.rbegin(), diff.rend() );
for( int i = 0; i < k -1; i ++ )
ans -= diff[i];
cout << ans;
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... |