답안 #754623

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
754623 2023-06-08T07:11:17 Z otarius Stove (JOI18_stove) C++17
100 / 100
54 ms 1316 KB
#include <bits/stdc++.h>
using namespace std;

#define ff first
#define sc second
#define pb push_back
#define ll long long
#define pii pair<int, int>
const ll mod = 1e9 + 7;

void solve() {
    int n, k;
    cin >> n >> k;
    int arr[n + 1];
    for (int i = 1; i <= n; i++)
        cin >> arr[i];
    vector<int> vals;
    sort(arr + 1, arr + n + 1);
    for (int i = 2; i <= n; i++)
        vals.pb(arr[i] - arr[i - 1]);
    int ans = 0;
    sort(vals.begin(), vals.end());
    for (int i = 0; i < n - k; i++)
        ans += vals[i];
    cout << ans + k;
}
int main() {
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
        cout << '\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 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 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 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 1 ms 212 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 2 ms 212 KB Output is correct
12 Correct 3 ms 212 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 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 1 ms 212 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 2 ms 212 KB Output is correct
12 Correct 3 ms 212 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
16 Correct 54 ms 1296 KB Output is correct
17 Correct 54 ms 1300 KB Output is correct
18 Correct 52 ms 1304 KB Output is correct
19 Correct 53 ms 1312 KB Output is correct
20 Correct 45 ms 1312 KB Output is correct
21 Correct 48 ms 1308 KB Output is correct
22 Correct 47 ms 1224 KB Output is correct
23 Correct 45 ms 1304 KB Output is correct
24 Correct 46 ms 1316 KB Output is correct