답안 #541628

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
541628 2022-03-23T23:00:09 Z Olympia Stove (JOI18_stove) C++17
100 / 100
20 ms 2284 KB
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
#include <cmath>
#include <map>
#include <random>
#include <cassert>
#include <ctime>
#include <cstdlib>
#include <limits.h>

using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, K;
    cin >> N >> K;
    K--;
    vector<int> arr(N);
    vector<int> dif;
    for (int i = 0; i < N; i++) {
        cin >> arr[i];
        if (i != 0) {
            dif.push_back(arr[i] - arr[i - 1] - 1);
        }
    }
    sort(dif.begin(), dif.end());
    int64_t ans = N;
    while (!dif.empty() && K--) {
        dif.pop_back();
    }
    while (!dif.empty()) {
        ans += dif.back();
        dif.pop_back();
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 19 ms 2256 KB Output is correct
17 Correct 20 ms 2200 KB Output is correct
18 Correct 19 ms 2236 KB Output is correct
19 Correct 18 ms 2252 KB Output is correct
20 Correct 20 ms 2144 KB Output is correct
21 Correct 20 ms 2240 KB Output is correct
22 Correct 18 ms 2236 KB Output is correct
23 Correct 18 ms 2284 KB Output is correct
24 Correct 17 ms 2140 KB Output is correct