This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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... |