제출 #783831

#제출 시각아이디문제언어결과실행 시간메모리
783831jeroenodbStove (JOI18_stove)C++14
100 / 100
45 ms1008 KiB
#include <bits/stdc++.h> using namespace std; #define loop(x) for (int i = 0; i < x; i++) int main() { int N, K; cin >> N >> K; // vector<int> T(N); priority_queue<int> gaps; int prevT = -1; int matchesUsed = 0; int burnTime = N; loop(N) { int t; cin >> t; if (prevT == -1 || t - prevT > 1) { matchesUsed++; if (prevT != -1) { gaps.push(prevT - t + 1); // -1 * gapSize } } prevT = t; // cin >> T[i]; } while (matchesUsed > K) { int g = -gaps.top(); gaps.pop(); matchesUsed--; burnTime += g; } cout << burnTime << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...