답안 #888899

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
888899 2023-12-18T11:04:11 Z Art_ogo Stove (JOI18_stove) C++17
100 / 100
43 ms 2952 KB
#include <bits/stdc++.h>

#define ve vector
#define ll long long
#define all(x) x.begin(), x.end()
using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    ve<ll> v(n);
    for(auto& i : v)
        cin >> i;
    sort(all(v));
    ll res = v.back() - v.front() + 1;
    ve<ll> a(n - 1);
    for(int i = 0; i < n - 1; i++)
        a[i] = v[i + 1] - v[i] - 1;
    sort(all(a), greater<ll>());
    for(int i = 0; i < k - 1; i++)
        res -= a[i];
    cout << res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 548 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 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 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 548 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 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 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 548 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 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 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 448 KB Output is correct
16 Correct 41 ms 2736 KB Output is correct
17 Correct 37 ms 2952 KB Output is correct
18 Correct 40 ms 2864 KB Output is correct
19 Correct 41 ms 2740 KB Output is correct
20 Correct 38 ms 2872 KB Output is correct
21 Correct 36 ms 2904 KB Output is correct
22 Correct 37 ms 2936 KB Output is correct
23 Correct 43 ms 2932 KB Output is correct
24 Correct 36 ms 2896 KB Output is correct