답안 #837534

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
837534 2023-08-25T11:59:47 Z Koyote Stove (JOI18_stove) C++11
100 / 100
18 ms 2132 KB
#include <bits/stdc++.h>
using namespace std;

const int maxN = 1e5 + 2;
int n, k, a[maxN], b[maxN];

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (i > 0) b[i - 1] = (a[i] - a[i - 1]) - 1;
    }
    sort(b, b + n - 1, greater<int>());
    cout << (a[n - 1] - a[0] + 1) - accumulate(b, b + k - 1, 0LL) << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 328 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 328 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 2 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 348 KB Output is correct
15 Correct 1 ms 352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 328 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 2 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 348 KB Output is correct
15 Correct 1 ms 352 KB Output is correct
16 Correct 17 ms 2052 KB Output is correct
17 Correct 15 ms 2072 KB Output is correct
18 Correct 14 ms 2132 KB Output is correct
19 Correct 18 ms 2052 KB Output is correct
20 Correct 14 ms 2004 KB Output is correct
21 Correct 14 ms 1972 KB Output is correct
22 Correct 14 ms 2068 KB Output is correct
23 Correct 14 ms 2004 KB Output is correct
24 Correct 14 ms 2032 KB Output is correct