제출 #1240555

#제출 시각아이디문제언어결과실행 시간메모리
1240555Nailuj_217Stove (JOI18_stove)C++20
100 / 100
37 ms2492 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const ll LEN = 1005; vector<ll> times; int main() { ll n, k; cin >> n >> k; ll a; for (int i = 0; i < n; i++) { cin >> a; times.push_back(a); } priority_queue<ll, vector<ll>, greater<ll>> pq; for (int i = 1; i < k; i++) pq.push(0); ll cnt = (ll)1e18 - 1; for (int i = times.size() - 1; i > 0; i--) { pq.push(times[i] - times[i-1] - 1); pq.pop(); cnt -= times[i] - times[i-1]; } ll sol = (ll)1e18 - cnt; while (pq.size()) { sol -= pq.top(); pq.pop(); } cout << sol << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...