제출 #1127240

#제출 시각아이디문제언어결과실행 시간메모리
1127240kizuStove (JOI18_stove)C++20
100 / 100
21 ms2244 KiB
#include <bits/stdc++.h> using namespace std ; #define is == #define isnt != #define endl '\n' #define ll long long //4557430888798830399 void Solve () { ll n, k ; cin >> n >> k ; k -- ; ll x [n] ; for (int i = 0 ; i < n ; i ++) cin >> x [i] ; priority_queue <ll> pq ; for (int i = 1 ; i < n ; i ++) pq.push (x [i] - x [i - 1] - 1) ; ll ans = x [n - 1] - x [0] + 1 ; while (k) { ans -= pq.top () ; pq.pop () ; k -- ; } cout << ans << endl ; } int main () { ios_base::sync_with_stdio (false) ; cin.tie (nullptr) ; cout.tie (nullptr) ; Solve () ; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...