제출 #1036703

#제출 시각아이디문제언어결과실행 시간메모리
1036703HotStepBrozStove (JOI18_stove)C++14
100 / 100
51 ms3320 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const ll N = 1e5 + 5 ; const ll INF = 0x3f3f3f3f3f3f3f3f ; const ll MOD = 1e9 + 7 ; ll n , k , a[N] , res = 0 ,ans = 0 ; vector< ll > v ; int main() { cin >> n >> k ; for( int i = 1 ; i <= n ; i++) cin >> a[i] ; for( int i = 2 ; i <= n ; i++) { v.push_back(a[i] - a[i-1] - 1 ) ; } sort( v.begin() , v.end() ) ; reverse(v.begin() , v.end() ) ; for( int i = 0 ; i < k -1 ; i++) res += v[i] ; cout << a[n] - a[1] + 1 - res << '\n' ; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...