# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
587641 |
2022-07-02T07:31:36 Z |
shrimb |
Stove (JOI18_stove) |
C++17 |
|
31 ms |
2776 KB |
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx,avx2,fma")
#include"bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class x>
using ordered_set = tree<x, null_type,less<x>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define endl '\n'
#define mod 1000000007
//\
#define mod 1686876991
// joi 2018 not aliens trick :(
int n, k;
int a[100001];
signed main () {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> k;
for (int i = 0 ; i < n ; i++) cin >> a[i];
sort(a, a + n);
int d[n - 1];
for (int i = 1 ; i < n ; i++) d[i-1] = a[i] - (a[i-1] + 1);
sort(d, d + n - 1);
int ans = a[n-1] - a[0] + 1;
k = min(k - 1, n - 1);
for (int i = 0 ; i < k ; i++) {
ans -= d[n - 2 - i];
}
cout << ans << endl;
}
Compilation message
stove.cpp:17:1: warning: multi-line comment [-Wcomment]
17 | //\
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
332 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 |
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 |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
368 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
332 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 |
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 |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
368 KB |
Output is correct |
16 |
Correct |
22 ms |
2048 KB |
Output is correct |
17 |
Correct |
30 ms |
2024 KB |
Output is correct |
18 |
Correct |
29 ms |
2012 KB |
Output is correct |
19 |
Correct |
30 ms |
2736 KB |
Output is correct |
20 |
Correct |
29 ms |
2000 KB |
Output is correct |
21 |
Correct |
21 ms |
2768 KB |
Output is correct |
22 |
Correct |
23 ms |
2776 KB |
Output is correct |
23 |
Correct |
31 ms |
2012 KB |
Output is correct |
24 |
Correct |
22 ms |
1960 KB |
Output is correct |