제출 #227895

#제출 시각아이디문제언어결과실행 시간메모리
227895BinyominStove (JOI18_stove)C++14
0 / 100
5 ms256 KiB
# 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...