Submission #783925

# Submission time Handle Problem Language Result Execution time Memory
783925 2023-07-15T12:26:10 Z Boas Stove (JOI18_stove) C++17
100 / 100
37 ms 896 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;
    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;
    }
    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 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 2 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 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 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 2 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 37 ms 896 KB Output is correct
17 Correct 37 ms 872 KB Output is correct
18 Correct 37 ms 840 KB Output is correct
19 Correct 36 ms 848 KB Output is correct
20 Correct 32 ms 848 KB Output is correct
21 Correct 30 ms 848 KB Output is correct
22 Correct 28 ms 864 KB Output is correct
23 Correct 28 ms 848 KB Output is correct
24 Correct 31 ms 872 KB Output is correct