Submission #698157

# Submission time Handle Problem Language Result Execution time Memory
698157 2023-02-12T15:43:43 Z Richem Stove (JOI18_stove) C++14
100 / 100
50 ms 1568 KB
#include <iostream>
#include <algorithm>

using namespace std;

const int MAX_GUEST = 1e5+42;

int nbGuest, nbSwitch;
int ecart[MAX_GUEST];

int total = 0;

int main() {
    cin >> nbGuest >> nbSwitch;

    int preced = 0;
    for(int cur = 0; cur < nbGuest; cur++) {
        int depart;
        cin >> depart;

        if(cur > 0) {
            ecart[cur-1] = preced - depart;
        }
        else {
            total = -depart;
        }

        preced = depart+1;
    }
    total += preced;

    sort(ecart, ecart + nbGuest-1);

    for(int trou = 0; trou < nbSwitch-1; trou++) {
        total += ecart[trou];
    }

    cout << total;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 304 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 308 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 304 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 308 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 308 KB Output is correct
10 Correct 2 ms 320 KB Output is correct
11 Correct 2 ms 340 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 324 KB Output is correct
15 Correct 2 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 304 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 308 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 308 KB Output is correct
10 Correct 2 ms 320 KB Output is correct
11 Correct 2 ms 340 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 324 KB Output is correct
15 Correct 2 ms 324 KB Output is correct
16 Correct 50 ms 1544 KB Output is correct
17 Correct 44 ms 1568 KB Output is correct
18 Correct 44 ms 1548 KB Output is correct
19 Correct 43 ms 1492 KB Output is correct
20 Correct 45 ms 1504 KB Output is correct
21 Correct 44 ms 1448 KB Output is correct
22 Correct 44 ms 1492 KB Output is correct
23 Correct 45 ms 1504 KB Output is correct
24 Correct 44 ms 1464 KB Output is correct