답안 #503590

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
503590 2022-01-08T11:32:43 Z the_horo Stove (JOI18_stove) C++17
100 / 100
55 ms 1076 KB
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>

int main () {
    int n, k;
    std::cin >> n >> k;

    std::vector<int> t(n);

    for (int &val: t)
        std::cin >> val;

    std::vector<int> helper(n - 1);
    for (size_t i = 0; i != helper.size(); ++ i)
        helper[i] = t[i + 1] - t[i];

    std::sort(helper.begin(), helper.end(), std::greater<int>{});

    unsigned int total_operation = t.back() - t.front() + 1;

    assert(static_cast<size_t>(k) - 1 <= helper.size());
    for (int i = 0; i < k - 1; ++ i)
        total_operation -= helper[i] - 1;

    std::cout << total_operation << std::endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 2 ms 204 KB Output is correct
11 Correct 2 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 2 ms 204 KB Output is correct
15 Correct 2 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 2 ms 204 KB Output is correct
11 Correct 2 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 2 ms 204 KB Output is correct
15 Correct 2 ms 204 KB Output is correct
16 Correct 43 ms 1072 KB Output is correct
17 Correct 47 ms 1060 KB Output is correct
18 Correct 55 ms 1072 KB Output is correct
19 Correct 51 ms 1072 KB Output is correct
20 Correct 42 ms 1076 KB Output is correct
21 Correct 51 ms 1064 KB Output is correct
22 Correct 44 ms 1056 KB Output is correct
23 Correct 46 ms 1068 KB Output is correct
24 Correct 48 ms 1056 KB Output is correct