# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
783751 |
2023-07-15T09:46:17 Z |
Boas |
Stove (JOI18_stove) |
C++17 |
|
45 ms |
1860 KB |
#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 |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
300 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
296 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
300 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
296 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
300 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
296 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
45 ms |
1776 KB |
Output is correct |
17 |
Correct |
38 ms |
1808 KB |
Output is correct |
18 |
Correct |
40 ms |
1736 KB |
Output is correct |
19 |
Correct |
38 ms |
1860 KB |
Output is correct |
20 |
Correct |
34 ms |
1800 KB |
Output is correct |
21 |
Correct |
30 ms |
1812 KB |
Output is correct |
22 |
Correct |
29 ms |
1752 KB |
Output is correct |
23 |
Correct |
37 ms |
1816 KB |
Output is correct |
24 |
Correct |
29 ms |
1744 KB |
Output is correct |