Submission #783777

# Submission time Handle Problem Language Result Execution time Memory
783777 2023-07-15T10:10:57 Z Boas Stove (JOI18_stove) C++17
100 / 100
37 ms 960 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);
    vector<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_back(-1 * (t - prevT - 1)); //  gapSize
            }
        }
        prevT = t;
        // cin >> T[i];
    }
    sort(gaps.begin(), gaps.end());
    int inx = gaps.size() - 1;
    while (matchesUsed > K)
    {
        int g = -gaps[inx];
        matchesUsed--;
        burnTime += g;
        inx--;
    }
    cout << burnTime << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 276 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 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 276 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 1 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 304 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 276 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 1 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 304 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 34 ms 860 KB Output is correct
17 Correct 33 ms 884 KB Output is correct
18 Correct 33 ms 960 KB Output is correct
19 Correct 37 ms 848 KB Output is correct
20 Correct 33 ms 848 KB Output is correct
21 Correct 33 ms 916 KB Output is correct
22 Correct 35 ms 828 KB Output is correct
23 Correct 34 ms 876 KB Output is correct
24 Correct 33 ms 832 KB Output is correct