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 ll long long
using namespace std ;
vector < int > vc ;
int n, k, T, pre, A[100001], l ;
ll sum ;
int main() {
cin >> n >> k ;
l = n;
for( int i = 0 ; i < n ; i ++ ) {
cin >> A[i] ;
if( i > 0 ) {
vc.push_back(A[i]-A[i-1]+1) ;
}
}
if( k >= n ) {
cout << k << endl;
return 0 ;
}
reverse(vc.begin(), vc.end() ) ;
for( size_t i = 0 ; i < vc.size() ; i ++ ) {
if( k == 1 ) sum += vc[i] ;
else {
k -- ;
sum += 1 ;
}
}
cout << sum << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |