# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
665845 |
2022-11-27T13:43:49 Z |
Bogdan1110 |
Stove (JOI18_stove) |
C++14 |
|
22 ms |
2648 KB |
#include <bits/stdc++.h>
#define FAST {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define FILES {freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);}
#define ll long long
#define ull unsigned long long
#define pqueue priority_queue
#define pb push_back
#define fi first
#define se second
#define ld long double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define vii vector<int>
#define vll vector<long long>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
*/
// order_of_key -> # less than k
// find_by_order -> k-th element
// pq max element
const double eps = 0.00000001;
const int NMAX = 200010;
const ll inf = 1000000000000010;
const ll modi = 15485863 ;
void solve() {
int n,k;
cin >>n >>k;
vector<ll>v(n);
for (int i = 0 ; i < n ; i++ ) {
cin >> v[i];
}
ll tot = n;
pqueue<int>pq;
for (int i = 1 ; i < n ; i++ ) {
pq.push(-v[i]+v[i-1]+1);
}
for (int i = 0 ; i < n-k; i++ ) {
tot -= pq.top();
pq.pop();
}
cout << tot <<endl;
}
int main () {
FAST
int t=1;
/*
cin >> t;
//*/
int i = 1;
while(t--) {
//cout << "Case " << i++ << ": " ;
solve();
}
}
Compilation message
stove.cpp: In function 'int main()':
stove.cpp:64:9: warning: unused variable 'i' [-Wunused-variable]
64 | int i = 1;
| ^
# |
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 |
0 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 |
0 ms |
320 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
316 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 |
0 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 |
0 ms |
320 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
316 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
376 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
340 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 |
0 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 |
0 ms |
320 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
316 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
376 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
22 ms |
2648 KB |
Output is correct |
17 |
Correct |
22 ms |
2620 KB |
Output is correct |
18 |
Correct |
22 ms |
2648 KB |
Output is correct |
19 |
Correct |
21 ms |
2644 KB |
Output is correct |
20 |
Correct |
18 ms |
2640 KB |
Output is correct |
21 |
Correct |
13 ms |
2636 KB |
Output is correct |
22 |
Correct |
15 ms |
2640 KB |
Output is correct |
23 |
Correct |
12 ms |
2640 KB |
Output is correct |
24 |
Correct |
13 ms |
2632 KB |
Output is correct |