답안 #915954

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
915954 2024-01-25T01:47:50 Z Matjaz Stove (JOI18_stove) C++14
100 / 100
34 ms 2140 KB
//
//  JOI18_STOVE.cpp
//  
//
//  Created by Matjaz Leonardis on 25/01/2024.
//

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N,K;
    cin >> N >> K;
    vector<int> T(N);
    vector<int> gap(N - 1);
    for (int i=0;i<N;i++){
        cin >> T[i];
        if (i > 0) gap[i - 1] = T[i] - T[i-1] - 1;
    }
    int time_on = T[N-1] - T[0] + 1;
    int ngaps = K - 1;
    sort(gap.rbegin(), gap.rend());
    for (int i=0;i<ngaps;i++) time_on -= gap[i];
    cout << time_on << endl;
    
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 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 1 ms 376 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 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 1 ms 376 KB Output is correct
9 Correct 1 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 2 ms 348 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 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 1 ms 376 KB Output is correct
9 Correct 1 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 2 ms 348 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 34 ms 2136 KB Output is correct
17 Correct 34 ms 2132 KB Output is correct
18 Correct 34 ms 2128 KB Output is correct
19 Correct 34 ms 2140 KB Output is correct
20 Correct 34 ms 2140 KB Output is correct
21 Correct 34 ms 1968 KB Output is correct
22 Correct 34 ms 2140 KB Output is correct
23 Correct 34 ms 2128 KB Output is correct
24 Correct 34 ms 2128 KB Output is correct