# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1113284 | 2024-11-16T09:42:40 Z | hpesoj | Stove (JOI18_stove) | C++17 | 26 ms | 3388 KB |
#include <bits/stdc++.h> #define int long long #define pi pair<int, int> #define ppi pair<pi, int> #define fi first #define se second #define pb push_back #define pf push_front #define mp make_pair #define all(x) x.begin(), x.end() #define debug(x) cout << #x << ": " << x << '\n' #define debug2(x, y) cout << #x << ": " << x << ' ' << #y << ": " << y << '\n' #define debug3(x, y, z) cout << #x << ": " << x << ' ' << #y << ": " << y << ' ' << #z << ": " << z << '\n' using namespace std; mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count()); const int inf = 1e18+5, mod = 1000000007; signed main(){ ios::sync_with_stdio(0), cin.tie(0); int n, k; cin >> n >> k; int t[n+1]; for(int i = 1; i <= n; i++) cin >> t[i]; int ans = n; priority_queue <int, vector <int>, greater <int>> pq; for(int i = 2; i <= n; i++) if(t[i] - t[i-1] > 1) pq.push(t[i] - t[i-1] - 1); while(pq.size() >= k) ans += pq.top(), pq.pop(); cout << ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 460 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 460 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 336 KB | Output is correct |
8 | Correct | 1 ms | 420 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 460 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 460 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 336 KB | Output is correct |
8 | Correct | 1 ms | 420 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
10 | Correct | 2 ms | 336 KB | Output is correct |
11 | Correct | 2 ms | 336 KB | Output is correct |
12 | Correct | 1 ms | 592 KB | Output is correct |
13 | Correct | 2 ms | 336 KB | Output is correct |
14 | Correct | 1 ms | 336 KB | Output is correct |
15 | Correct | 2 ms | 476 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 460 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 460 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 336 KB | Output is correct |
8 | Correct | 1 ms | 420 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
10 | Correct | 2 ms | 336 KB | Output is correct |
11 | Correct | 2 ms | 336 KB | Output is correct |
12 | Correct | 1 ms | 592 KB | Output is correct |
13 | Correct | 2 ms | 336 KB | Output is correct |
14 | Correct | 1 ms | 336 KB | Output is correct |
15 | Correct | 2 ms | 476 KB | Output is correct |
16 | Correct | 26 ms | 3388 KB | Output is correct |
17 | Correct | 21 ms | 3252 KB | Output is correct |
18 | Correct | 25 ms | 3360 KB | Output is correct |
19 | Correct | 26 ms | 3280 KB | Output is correct |
20 | Correct | 17 ms | 3280 KB | Output is correct |
21 | Correct | 14 ms | 3280 KB | Output is correct |
22 | Correct | 15 ms | 3272 KB | Output is correct |
23 | Correct | 11 ms | 3280 KB | Output is correct |
24 | Correct | 11 ms | 3280 KB | Output is correct |