Submission #964170

# Submission time Handle Problem Language Result Execution time Memory
964170 2024-04-16T11:45:18 Z mel Stove (JOI18_stove) C++14
100 / 100
44 ms 2928 KB
#include <iostream>
using namespace std;
#include <algorithm>
#define int long long

int arr[100005];
int dif[100005];

signed main() {
        int n; cin >> n;
        int k; cin >> k;
        for (int i =0; i<n; i++){
                cin >> arr[i];
        }
        sort(arr, arr+n);
        for(int i = 0;i<(n-1);i++){
                dif[i] = arr[i+1]-arr[i];
        }
        sort(dif, dif+(n-1));
        if (k>=n) {
                cout << n;
        } else {
                int cnt = k;

                for (int i = 0; i<(n-k); i++) {
                        cnt+= dif[i];
                }
                cout << cnt;
        }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 360 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 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 0 ms 444 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 360 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 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 0 ms 444 KB Output is correct
9 Correct 1 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 2 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 2 ms 488 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 360 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 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 0 ms 444 KB Output is correct
9 Correct 1 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 2 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 2 ms 488 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 36 ms 2928 KB Output is correct
17 Correct 44 ms 2896 KB Output is correct
18 Correct 35 ms 2908 KB Output is correct
19 Correct 38 ms 2896 KB Output is correct
20 Correct 35 ms 2748 KB Output is correct
21 Correct 35 ms 2764 KB Output is correct
22 Correct 36 ms 2744 KB Output is correct
23 Correct 35 ms 2900 KB Output is correct
24 Correct 35 ms 2900 KB Output is correct