Submission #875188

# Submission time Handle Problem Language Result Execution time Memory
875188 2023-11-18T18:44:23 Z misu2005 Stove (JOI18_stove) C++11
100 / 100
34 ms 1964 KB
#include <iostream>
#include <algorithm>

using namespace std;

long long n, k, x, v[100002], lastx, rez;

int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> x;
        if (i != 1) {
            v[i-1] = x-lastx-1;
        }
        lastx = x;
    }

    rez = n;
    sort(v+1, v+n);

    long long poz = n-k;
    for (long long i = 1; i <= poz; i++)
        rez += v[i];
    cout << rez;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 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 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 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 484 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 604 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 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 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 484 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 604 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 348 KB Output is correct
16 Correct 34 ms 1868 KB Output is correct
17 Correct 33 ms 1788 KB Output is correct
18 Correct 33 ms 1884 KB Output is correct
19 Correct 33 ms 1876 KB Output is correct
20 Correct 33 ms 1872 KB Output is correct
21 Correct 34 ms 1964 KB Output is correct
22 Correct 34 ms 1724 KB Output is correct
23 Correct 34 ms 1876 KB Output is correct
24 Correct 33 ms 1836 KB Output is correct