# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
528006 |
2022-02-19T01:58:14 Z |
Hydrolyzed |
Stove (JOI18_stove) |
C++14 |
|
24 ms |
2300 KB |
/*
* AUTHOR : Hydrolyzed~
* SCHOOL : RYW
* TASK : JOI18_Stove
* ALGO :
* DATE : 19 Feb 2022
* */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
// @==== Libary ====@ //
// @================@ //
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update> ;
// @=== Debugger ===@ //
#ifdef _DEBUG
#include "debug.hpp"
#else
#define dbg(...) 0
#endif
// @================@ //
using ll = long long;
const int MxN = 100100;
priority_queue<int> pq;
int a[MxN];
inline void solution(){
int n, k;
cin >> n >> k;
for(int i=1; i<=n; ++i){
cin >> a[i];
}
int res = a[n] - a[1] + 1;
for(int i=1; i<n; ++i){
pq.push(a[i + 1] - a[i] - 1);
}
while(!pq.empty(), --k){
res -= pq.top();
pq.pop();
}
cout << res;
return ;
}
signed main(){
cin.tie(nullptr)->ios::sync_with_stdio(false);
int q = 1;
// cin >> q;
while(q--){
solution();
cout << "\n";
}
return 0;
}
// https://github.com/MasterIceZ/archive/tree/main/cpp-template
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
320 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
320 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
320 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
396 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
320 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
320 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
396 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
12 ms |
2252 KB |
Output is correct |
17 |
Correct |
13 ms |
2248 KB |
Output is correct |
18 |
Correct |
15 ms |
2300 KB |
Output is correct |
19 |
Correct |
12 ms |
2196 KB |
Output is correct |
20 |
Correct |
18 ms |
2244 KB |
Output is correct |
21 |
Correct |
21 ms |
2272 KB |
Output is correct |
22 |
Correct |
21 ms |
2296 KB |
Output is correct |
23 |
Correct |
24 ms |
2252 KB |
Output is correct |
24 |
Correct |
21 ms |
2216 KB |
Output is correct |