이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |