Submission #625246

# Submission time Handle Problem Language Result Execution time Memory
625246 2022-08-09T17:14:41 Z Genius3435 Stove (JOI18_stove) C++17
100 / 100
63 ms 2072 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, k; cin >> n >> k;
    vector<int> a (n);
    for (int &x : a) cin >> x;

    vector<int> diff (n-1);
    for (int i = 0; i < n-1; ++i) {
        if (a[i+1] == a[i]+1) continue;
        diff[i] = a[i+1] - a[i] - 1;
    }
    sort(diff.begin(), diff.end());

    int ans = 0;
    for (int i = 0; i < n-k; ++i) {
        ans += diff[i];
    }

    cout << ans+n << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 296 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 300 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 296 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 300 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 296 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 316 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 312 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 296 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 300 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 296 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 316 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 312 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 56 ms 1960 KB Output is correct
17 Correct 48 ms 2072 KB Output is correct
18 Correct 44 ms 1964 KB Output is correct
19 Correct 45 ms 1952 KB Output is correct
20 Correct 45 ms 1996 KB Output is correct
21 Correct 44 ms 1996 KB Output is correct
22 Correct 45 ms 1996 KB Output is correct
23 Correct 45 ms 1964 KB Output is correct
24 Correct 63 ms 2036 KB Output is correct