Submission #1014711

# Submission time Handle Problem Language Result Execution time Memory
1014711 2024-07-05T10:21:31 Z avighna Stove (JOI18_stove) C++17
100 / 100
38 ms 3020 KB
#include <bits/stdc++.h>

typedef long long ll;

int main() {
    int n, k;
    std::cin >> n >> k;
    std::vector<ll> a(n);
    for (auto &i : a) {
        std::cin >> i;
    }
    std::vector<int> gaps;
    for (int i = 0; i < n - 1; ++i) {
        gaps.push_back(a[i + 1] - a[i] - 1);
    }
    std::sort(gaps.begin(), gaps.end());
    int ans = n;
    int used = n;
    int idx = 0;
    while (used > k) {
        used--;
        ans += gaps[idx++];
    }
    std::cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 31 ms 2564 KB Output is correct
17 Correct 36 ms 2768 KB Output is correct
18 Correct 33 ms 2768 KB Output is correct
19 Correct 30 ms 2752 KB Output is correct
20 Correct 30 ms 2776 KB Output is correct
21 Correct 38 ms 3020 KB Output is correct
22 Correct 35 ms 2768 KB Output is correct
23 Correct 30 ms 2776 KB Output is correct
24 Correct 37 ms 2776 KB Output is correct