Submission #204698

# Submission time Handle Problem Language Result Execution time Memory
204698 2020-02-26T17:16:17 Z bogdan_ogorodniy Stove (JOI18_stove) C++14
100 / 100
86 ms 2292 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 5 * 1e3 + 1;
const int inf = 1e9 + 7;

signed main() {
    int n, k;
    cin >> n >> k;
    vector <int> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    vector <int> vv;
    int dist = 0;
    for (int i = 1; i < n; i++) {
        vv.push_back(v[i] - v[i - 1]);
    }
    sort(vv.begin(), vv.end());
    for (int i = 0; i < n - k; i++) dist += vv[i];
    dist += k;
    cout << dist << '\n';
    return 0;
} 
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 380 KB Output is correct
10 Correct 7 ms 376 KB Output is correct
11 Correct 7 ms 376 KB Output is correct
12 Correct 7 ms 376 KB Output is correct
13 Correct 7 ms 376 KB Output is correct
14 Correct 7 ms 376 KB Output is correct
15 Correct 7 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 380 KB Output is correct
10 Correct 7 ms 376 KB Output is correct
11 Correct 7 ms 376 KB Output is correct
12 Correct 7 ms 376 KB Output is correct
13 Correct 7 ms 376 KB Output is correct
14 Correct 7 ms 376 KB Output is correct
15 Correct 7 ms 380 KB Output is correct
16 Correct 80 ms 2292 KB Output is correct
17 Correct 77 ms 2248 KB Output is correct
18 Correct 79 ms 2292 KB Output is correct
19 Correct 84 ms 2292 KB Output is correct
20 Correct 83 ms 2292 KB Output is correct
21 Correct 86 ms 2292 KB Output is correct
22 Correct 80 ms 2292 KB Output is correct
23 Correct 76 ms 2292 KB Output is correct
24 Correct 83 ms 2292 KB Output is correct