답안 #587025

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
587025 2022-07-01T08:16:51 Z snasibov05 Stove (JOI18_stove) C++14
100 / 100
61 ms 1708 KB
#include <bits/stdc++.h>

using namespace std;

int main() {

    int n, k; cin >> n >> k;
    vector<int> t(n);
    for (int i = 0; i < n; ++i) cin >> t[i];

    vector<bool> stop(n); stop[n-1] = true;
    vector<pair<int, int>> dif(n-1);
    for (int i = 0; i < n-1; ++i) dif[i] = {t[i+1] - t[i], i};
    sort(dif.rbegin(), dif.rend());

    for (int i = 0; i < k-1; ++i) stop[dif[i].second] = true;

    int prev = t[0];
    int ans = 0;
    for (int i = 0; i < n; ++i){
        if (!stop[i]) continue;
        ans += t[i] - prev + 1;
        if (i != n-1) prev = t[i+1];
    }

    cout << ans << "\n";

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 0 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 296 KB Output is correct
6 Correct 0 ms 300 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 0 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 296 KB Output is correct
6 Correct 0 ms 300 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 316 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 0 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 296 KB Output is correct
6 Correct 0 ms 300 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 316 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 53 ms 1616 KB Output is correct
17 Correct 47 ms 1648 KB Output is correct
18 Correct 61 ms 1640 KB Output is correct
19 Correct 50 ms 1652 KB Output is correct
20 Correct 49 ms 1676 KB Output is correct
21 Correct 47 ms 1608 KB Output is correct
22 Correct 46 ms 1620 KB Output is correct
23 Correct 53 ms 1672 KB Output is correct
24 Correct 52 ms 1708 KB Output is correct