Submission #476337

# Submission time Handle Problem Language Result Execution time Memory
476337 2021-09-26T05:11:55 Z palilo Stove (JOI18_stove) C++17
100 / 100
26 ms 1612 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
#ifdef palilo
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int n, k;
    cin >> n >> k;
    vector<int> a(n - 1);
    {
        int prv, cur;
        cin >> prv;
        for (auto& x : a) {
            cin >> cur;
            x = cur - prv;
            prv = cur;
        }
    }
    sort(a.begin(), a.end());
    const auto res = accumulate(a.begin(), a.end() - (k - 1), 0);
    cout << res + k;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 360 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 360 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 21 ms 1604 KB Output is correct
17 Correct 19 ms 1612 KB Output is correct
18 Correct 20 ms 1596 KB Output is correct
19 Correct 26 ms 1600 KB Output is correct
20 Correct 26 ms 1592 KB Output is correct
21 Correct 21 ms 1612 KB Output is correct
22 Correct 20 ms 1608 KB Output is correct
23 Correct 19 ms 1612 KB Output is correct
24 Correct 20 ms 1596 KB Output is correct