Submission #988285

# Submission time Handle Problem Language Result Execution time Memory
988285 2024-05-24T12:05:47 Z Wane Stove (JOI18_stove) C++14
100 / 100
43 ms 3372 KB
#include <bits/stdc++.h>

using namespace std;
#define int long long

int N, K;
int T[100001];

signed main() {

    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> T[i];
    }

    int to_connect = N - K;
    priority_queue<int, vector<int>, greater<int> > pq;
    for (int i = 1; i < N; i++) {
        pq.push(T[i] - T[i - 1]);
    }

    int ans = N;
    while (to_connect) {
        ans += pq.top() - 1;
        pq.pop();
        to_connect--;
    }
    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 39 ms 3276 KB Output is correct
17 Correct 39 ms 3160 KB Output is correct
18 Correct 43 ms 3372 KB Output is correct
19 Correct 38 ms 3280 KB Output is correct
20 Correct 34 ms 3284 KB Output is correct
21 Correct 31 ms 3148 KB Output is correct
22 Correct 31 ms 3348 KB Output is correct
23 Correct 33 ms 3276 KB Output is correct
24 Correct 30 ms 3272 KB Output is correct