# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1042221 |
2024-08-02T16:23:46 Z |
flappybird |
Sushi (JOI16_sushi) |
C++17 |
|
7585 ms |
94544 KB |
//#define LOCAL
#include <bits/stdc++.h>
#include <cassert>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define MAX 1010101
#define MAXQ 101010
#define INF 1'000'000'100
#define bb ' '
#define ln '\n'
#define Ln '\n'
#define MOD 1000000007
#define TC 1
#ifdef LOCAL
#define DEBUG(a) cout<<a
#else
#define DEBUG(...) 1234
#endif
#define B 2000
int A[MAX];
priority_queue<int> all[MAX];
priority_queue<int, vector<int>, greater<int>> upd[MAX];
int N, Q;
void refresh(int id) {
int i;
while (all[id].size()) all[id].pop();
for (i = id * B; i < min(N, (id + 1) * B); i++) all[id].push(A[i]);
}
void prop(int id) {
int i;
for (i = id * B; i < min(N, (id + 1) * B); i++) {
upd[id].emplace(A[i]);
A[i] = upd[id].top();
upd[id].pop();
}
upd[id] = {};
}
signed main() {
ios::sync_with_stdio(false), cin.tie(0);
cin >> N >> Q;
int i;
for (i = 0; i < N; i++) cin >> A[i];
auto f = [&](int l, int r, int x) {
int i;
i = l;
while (i <= r) {
int b = i / B;
if ((i % B == 0) && i + B - 1 <= r) {
//DEBUG("ii" << i << ln);
if (upd[b].empty()) refresh(b);
upd[b].push(x);
all[b].push(x);
x = all[b].top();
all[b].pop();
i += B;
//DEBUG('x' << x << bb);
}
else {
if (upd[b].size()) prop(b);
//DEBUG('i' << i << bb << A[i] << bb << x << ln);
if (A[i] > x) swap(A[i], x);
i++;
//DEBUG('y' << x << bb);
}
}
return x;
};
while (Q--) {
int l, r, x;
cin >> l >> r >> x;
l--;
r--;
if (l > r) {
x = f(l, N - 1, x);
x = f(0, r, x);
}
else x = f(l, r, x);
cout << x << ln;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
64092 KB |
Output is correct |
2 |
Correct |
17 ms |
64092 KB |
Output is correct |
3 |
Correct |
17 ms |
64092 KB |
Output is correct |
4 |
Correct |
17 ms |
64092 KB |
Output is correct |
5 |
Correct |
17 ms |
64092 KB |
Output is correct |
6 |
Correct |
18 ms |
64172 KB |
Output is correct |
7 |
Correct |
18 ms |
64092 KB |
Output is correct |
8 |
Correct |
21 ms |
64088 KB |
Output is correct |
9 |
Correct |
19 ms |
64092 KB |
Output is correct |
10 |
Correct |
17 ms |
64220 KB |
Output is correct |
11 |
Correct |
17 ms |
64092 KB |
Output is correct |
12 |
Correct |
18 ms |
64088 KB |
Output is correct |
13 |
Correct |
20 ms |
64092 KB |
Output is correct |
14 |
Correct |
21 ms |
64092 KB |
Output is correct |
15 |
Correct |
22 ms |
64092 KB |
Output is correct |
16 |
Correct |
12 ms |
64088 KB |
Output is correct |
17 |
Correct |
14 ms |
64092 KB |
Output is correct |
18 |
Correct |
14 ms |
64248 KB |
Output is correct |
19 |
Correct |
12 ms |
64092 KB |
Output is correct |
20 |
Correct |
14 ms |
64092 KB |
Output is correct |
21 |
Correct |
12 ms |
64140 KB |
Output is correct |
22 |
Correct |
13 ms |
64092 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
592 ms |
90308 KB |
Output is correct |
2 |
Correct |
593 ms |
90196 KB |
Output is correct |
3 |
Correct |
277 ms |
89972 KB |
Output is correct |
4 |
Correct |
577 ms |
90196 KB |
Output is correct |
5 |
Correct |
310 ms |
90396 KB |
Output is correct |
6 |
Correct |
563 ms |
90196 KB |
Output is correct |
7 |
Correct |
571 ms |
90192 KB |
Output is correct |
8 |
Correct |
564 ms |
90196 KB |
Output is correct |
9 |
Correct |
246 ms |
89940 KB |
Output is correct |
10 |
Correct |
303 ms |
90396 KB |
Output is correct |
11 |
Correct |
259 ms |
89940 KB |
Output is correct |
12 |
Correct |
493 ms |
90064 KB |
Output is correct |
13 |
Correct |
593 ms |
90192 KB |
Output is correct |
14 |
Correct |
613 ms |
90244 KB |
Output is correct |
15 |
Correct |
181 ms |
90140 KB |
Output is correct |
16 |
Correct |
585 ms |
90192 KB |
Output is correct |
17 |
Correct |
538 ms |
90192 KB |
Output is correct |
18 |
Correct |
565 ms |
90192 KB |
Output is correct |
19 |
Correct |
563 ms |
90192 KB |
Output is correct |
20 |
Correct |
403 ms |
90380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
64092 KB |
Output is correct |
2 |
Correct |
17 ms |
64092 KB |
Output is correct |
3 |
Correct |
17 ms |
64092 KB |
Output is correct |
4 |
Correct |
17 ms |
64092 KB |
Output is correct |
5 |
Correct |
17 ms |
64092 KB |
Output is correct |
6 |
Correct |
18 ms |
64172 KB |
Output is correct |
7 |
Correct |
18 ms |
64092 KB |
Output is correct |
8 |
Correct |
21 ms |
64088 KB |
Output is correct |
9 |
Correct |
19 ms |
64092 KB |
Output is correct |
10 |
Correct |
17 ms |
64220 KB |
Output is correct |
11 |
Correct |
17 ms |
64092 KB |
Output is correct |
12 |
Correct |
18 ms |
64088 KB |
Output is correct |
13 |
Correct |
20 ms |
64092 KB |
Output is correct |
14 |
Correct |
21 ms |
64092 KB |
Output is correct |
15 |
Correct |
22 ms |
64092 KB |
Output is correct |
16 |
Correct |
12 ms |
64088 KB |
Output is correct |
17 |
Correct |
14 ms |
64092 KB |
Output is correct |
18 |
Correct |
14 ms |
64248 KB |
Output is correct |
19 |
Correct |
12 ms |
64092 KB |
Output is correct |
20 |
Correct |
14 ms |
64092 KB |
Output is correct |
21 |
Correct |
12 ms |
64140 KB |
Output is correct |
22 |
Correct |
13 ms |
64092 KB |
Output is correct |
23 |
Correct |
592 ms |
90308 KB |
Output is correct |
24 |
Correct |
593 ms |
90196 KB |
Output is correct |
25 |
Correct |
277 ms |
89972 KB |
Output is correct |
26 |
Correct |
577 ms |
90196 KB |
Output is correct |
27 |
Correct |
310 ms |
90396 KB |
Output is correct |
28 |
Correct |
563 ms |
90196 KB |
Output is correct |
29 |
Correct |
571 ms |
90192 KB |
Output is correct |
30 |
Correct |
564 ms |
90196 KB |
Output is correct |
31 |
Correct |
246 ms |
89940 KB |
Output is correct |
32 |
Correct |
303 ms |
90396 KB |
Output is correct |
33 |
Correct |
259 ms |
89940 KB |
Output is correct |
34 |
Correct |
493 ms |
90064 KB |
Output is correct |
35 |
Correct |
593 ms |
90192 KB |
Output is correct |
36 |
Correct |
613 ms |
90244 KB |
Output is correct |
37 |
Correct |
181 ms |
90140 KB |
Output is correct |
38 |
Correct |
585 ms |
90192 KB |
Output is correct |
39 |
Correct |
538 ms |
90192 KB |
Output is correct |
40 |
Correct |
565 ms |
90192 KB |
Output is correct |
41 |
Correct |
563 ms |
90192 KB |
Output is correct |
42 |
Correct |
403 ms |
90380 KB |
Output is correct |
43 |
Correct |
6994 ms |
67152 KB |
Output is correct |
44 |
Correct |
7018 ms |
67156 KB |
Output is correct |
45 |
Correct |
3766 ms |
66832 KB |
Output is correct |
46 |
Correct |
6932 ms |
67160 KB |
Output is correct |
47 |
Correct |
6934 ms |
67152 KB |
Output is correct |
48 |
Correct |
6530 ms |
67156 KB |
Output is correct |
49 |
Correct |
7585 ms |
71504 KB |
Output is correct |
50 |
Correct |
7419 ms |
71508 KB |
Output is correct |
51 |
Correct |
7521 ms |
71508 KB |
Output is correct |
52 |
Correct |
4034 ms |
71904 KB |
Output is correct |
53 |
Correct |
4059 ms |
71624 KB |
Output is correct |
54 |
Correct |
3890 ms |
71932 KB |
Output is correct |
55 |
Correct |
4634 ms |
71764 KB |
Output is correct |
56 |
Correct |
4623 ms |
71788 KB |
Output is correct |
57 |
Correct |
4553 ms |
71764 KB |
Output is correct |
58 |
Correct |
3386 ms |
71508 KB |
Output is correct |
59 |
Correct |
3828 ms |
71696 KB |
Output is correct |
60 |
Correct |
652 ms |
94532 KB |
Output is correct |
61 |
Correct |
761 ms |
94536 KB |
Output is correct |
62 |
Correct |
797 ms |
94544 KB |
Output is correct |
63 |
Correct |
758 ms |
94424 KB |
Output is correct |
64 |
Correct |
2076 ms |
67976 KB |
Output is correct |
65 |
Correct |
436 ms |
81748 KB |
Output is correct |
66 |
Correct |
732 ms |
81744 KB |
Output is correct |
67 |
Correct |
690 ms |
84460 KB |
Output is correct |
68 |
Correct |
694 ms |
84468 KB |
Output is correct |
69 |
Correct |
690 ms |
84468 KB |
Output is correct |
70 |
Correct |
505 ms |
84608 KB |
Output is correct |