#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2010;
int n, m, q;
deque<pair<int, ll>> g[N];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin >> n >> m >> q;
if(n <= 2000 && q <= 2000) {
for(int i = 0; i < q; i++) {
int t;
cin >> t;
if(t == 1) {
ll l, r, c, k;
cin >> l >> r >> c >> k;
for(int j = l; j <= r; j++) {
g[j].push_back({c, k});
}
}
if(t == 2) {
ll l, r, k;
cin >> l >> r >> k;
for(int j = l; j <= r; j++) {
int p = k;
while(!g[j].empty() && g[j].front().second <= p) {
p -= g[j].front().second;
g[j].pop_front();
}
if(!g[j].empty())
g[j][0].second -= p;
}
}
if(t == 3) {
ll a, b;
cin >> a >> b;
int ans = 0;
for(auto [c, k] : g[a]) {
if(b > k) b -= k;
else {ans = c; break;}
}
cout << ans << '\n';
}
}
return 0;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2132 KB |
Output is correct |
2 |
Correct |
5 ms |
2388 KB |
Output is correct |
3 |
Correct |
7 ms |
9000 KB |
Output is correct |
4 |
Correct |
11 ms |
12628 KB |
Output is correct |
5 |
Correct |
1 ms |
1620 KB |
Output is correct |
6 |
Correct |
1 ms |
1620 KB |
Output is correct |
7 |
Correct |
15 ms |
14232 KB |
Output is correct |
8 |
Correct |
11 ms |
9812 KB |
Output is correct |
9 |
Correct |
7 ms |
2500 KB |
Output is correct |
10 |
Correct |
10 ms |
9300 KB |
Output is correct |
11 |
Correct |
10 ms |
6356 KB |
Output is correct |
12 |
Correct |
8 ms |
2516 KB |
Output is correct |
13 |
Correct |
10 ms |
2592 KB |
Output is correct |
14 |
Correct |
13 ms |
3736 KB |
Output is correct |
15 |
Correct |
8 ms |
4568 KB |
Output is correct |
16 |
Correct |
13 ms |
3668 KB |
Output is correct |
17 |
Correct |
4 ms |
2004 KB |
Output is correct |
18 |
Correct |
6 ms |
2132 KB |
Output is correct |
19 |
Correct |
1 ms |
1620 KB |
Output is correct |
20 |
Correct |
2 ms |
1620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2132 KB |
Output is correct |
2 |
Correct |
5 ms |
2388 KB |
Output is correct |
3 |
Correct |
7 ms |
9000 KB |
Output is correct |
4 |
Correct |
11 ms |
12628 KB |
Output is correct |
5 |
Correct |
1 ms |
1620 KB |
Output is correct |
6 |
Correct |
1 ms |
1620 KB |
Output is correct |
7 |
Correct |
15 ms |
14232 KB |
Output is correct |
8 |
Correct |
11 ms |
9812 KB |
Output is correct |
9 |
Correct |
7 ms |
2500 KB |
Output is correct |
10 |
Correct |
10 ms |
9300 KB |
Output is correct |
11 |
Correct |
10 ms |
6356 KB |
Output is correct |
12 |
Correct |
8 ms |
2516 KB |
Output is correct |
13 |
Correct |
10 ms |
2592 KB |
Output is correct |
14 |
Correct |
13 ms |
3736 KB |
Output is correct |
15 |
Correct |
8 ms |
4568 KB |
Output is correct |
16 |
Correct |
13 ms |
3668 KB |
Output is correct |
17 |
Correct |
4 ms |
2004 KB |
Output is correct |
18 |
Correct |
6 ms |
2132 KB |
Output is correct |
19 |
Correct |
1 ms |
1620 KB |
Output is correct |
20 |
Correct |
2 ms |
1620 KB |
Output is correct |
21 |
Correct |
6 ms |
2388 KB |
Output is correct |
22 |
Correct |
7 ms |
2516 KB |
Output is correct |
23 |
Correct |
8 ms |
9044 KB |
Output is correct |
24 |
Correct |
13 ms |
12760 KB |
Output is correct |
25 |
Correct |
1 ms |
1620 KB |
Output is correct |
26 |
Correct |
1 ms |
1684 KB |
Output is correct |
27 |
Correct |
15 ms |
13672 KB |
Output is correct |
28 |
Correct |
14 ms |
10520 KB |
Output is correct |
29 |
Correct |
9 ms |
4308 KB |
Output is correct |
30 |
Correct |
12 ms |
8916 KB |
Output is correct |
31 |
Correct |
11 ms |
6356 KB |
Output is correct |
32 |
Correct |
8 ms |
2388 KB |
Output is correct |
33 |
Correct |
9 ms |
2564 KB |
Output is correct |
34 |
Correct |
13 ms |
4788 KB |
Output is correct |
35 |
Correct |
8 ms |
3284 KB |
Output is correct |
36 |
Correct |
12 ms |
3684 KB |
Output is correct |
37 |
Correct |
1 ms |
1620 KB |
Output is correct |
38 |
Correct |
2 ms |
1624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1620 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1620 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2132 KB |
Output is correct |
2 |
Correct |
5 ms |
2388 KB |
Output is correct |
3 |
Correct |
7 ms |
9000 KB |
Output is correct |
4 |
Correct |
11 ms |
12628 KB |
Output is correct |
5 |
Correct |
1 ms |
1620 KB |
Output is correct |
6 |
Correct |
1 ms |
1620 KB |
Output is correct |
7 |
Correct |
15 ms |
14232 KB |
Output is correct |
8 |
Correct |
11 ms |
9812 KB |
Output is correct |
9 |
Correct |
7 ms |
2500 KB |
Output is correct |
10 |
Correct |
10 ms |
9300 KB |
Output is correct |
11 |
Correct |
10 ms |
6356 KB |
Output is correct |
12 |
Correct |
8 ms |
2516 KB |
Output is correct |
13 |
Correct |
10 ms |
2592 KB |
Output is correct |
14 |
Correct |
13 ms |
3736 KB |
Output is correct |
15 |
Correct |
8 ms |
4568 KB |
Output is correct |
16 |
Correct |
13 ms |
3668 KB |
Output is correct |
17 |
Correct |
4 ms |
2004 KB |
Output is correct |
18 |
Correct |
6 ms |
2132 KB |
Output is correct |
19 |
Correct |
1 ms |
1620 KB |
Output is correct |
20 |
Correct |
2 ms |
1620 KB |
Output is correct |
21 |
Incorrect |
1 ms |
1620 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1624 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2132 KB |
Output is correct |
2 |
Correct |
5 ms |
2388 KB |
Output is correct |
3 |
Correct |
7 ms |
9000 KB |
Output is correct |
4 |
Correct |
11 ms |
12628 KB |
Output is correct |
5 |
Correct |
1 ms |
1620 KB |
Output is correct |
6 |
Correct |
1 ms |
1620 KB |
Output is correct |
7 |
Correct |
15 ms |
14232 KB |
Output is correct |
8 |
Correct |
11 ms |
9812 KB |
Output is correct |
9 |
Correct |
7 ms |
2500 KB |
Output is correct |
10 |
Correct |
10 ms |
9300 KB |
Output is correct |
11 |
Correct |
10 ms |
6356 KB |
Output is correct |
12 |
Correct |
8 ms |
2516 KB |
Output is correct |
13 |
Correct |
10 ms |
2592 KB |
Output is correct |
14 |
Correct |
13 ms |
3736 KB |
Output is correct |
15 |
Correct |
8 ms |
4568 KB |
Output is correct |
16 |
Correct |
13 ms |
3668 KB |
Output is correct |
17 |
Correct |
4 ms |
2004 KB |
Output is correct |
18 |
Correct |
6 ms |
2132 KB |
Output is correct |
19 |
Correct |
1 ms |
1620 KB |
Output is correct |
20 |
Correct |
2 ms |
1620 KB |
Output is correct |
21 |
Correct |
6 ms |
2388 KB |
Output is correct |
22 |
Correct |
7 ms |
2516 KB |
Output is correct |
23 |
Correct |
8 ms |
9044 KB |
Output is correct |
24 |
Correct |
13 ms |
12760 KB |
Output is correct |
25 |
Correct |
1 ms |
1620 KB |
Output is correct |
26 |
Correct |
1 ms |
1684 KB |
Output is correct |
27 |
Correct |
15 ms |
13672 KB |
Output is correct |
28 |
Correct |
14 ms |
10520 KB |
Output is correct |
29 |
Correct |
9 ms |
4308 KB |
Output is correct |
30 |
Correct |
12 ms |
8916 KB |
Output is correct |
31 |
Correct |
11 ms |
6356 KB |
Output is correct |
32 |
Correct |
8 ms |
2388 KB |
Output is correct |
33 |
Correct |
9 ms |
2564 KB |
Output is correct |
34 |
Correct |
13 ms |
4788 KB |
Output is correct |
35 |
Correct |
8 ms |
3284 KB |
Output is correct |
36 |
Correct |
12 ms |
3684 KB |
Output is correct |
37 |
Correct |
1 ms |
1620 KB |
Output is correct |
38 |
Correct |
2 ms |
1624 KB |
Output is correct |
39 |
Incorrect |
1 ms |
1620 KB |
Output isn't correct |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2132 KB |
Output is correct |
2 |
Correct |
5 ms |
2388 KB |
Output is correct |
3 |
Correct |
7 ms |
9000 KB |
Output is correct |
4 |
Correct |
11 ms |
12628 KB |
Output is correct |
5 |
Correct |
1 ms |
1620 KB |
Output is correct |
6 |
Correct |
1 ms |
1620 KB |
Output is correct |
7 |
Correct |
15 ms |
14232 KB |
Output is correct |
8 |
Correct |
11 ms |
9812 KB |
Output is correct |
9 |
Correct |
7 ms |
2500 KB |
Output is correct |
10 |
Correct |
10 ms |
9300 KB |
Output is correct |
11 |
Correct |
10 ms |
6356 KB |
Output is correct |
12 |
Correct |
8 ms |
2516 KB |
Output is correct |
13 |
Correct |
10 ms |
2592 KB |
Output is correct |
14 |
Correct |
13 ms |
3736 KB |
Output is correct |
15 |
Correct |
8 ms |
4568 KB |
Output is correct |
16 |
Correct |
13 ms |
3668 KB |
Output is correct |
17 |
Correct |
4 ms |
2004 KB |
Output is correct |
18 |
Correct |
6 ms |
2132 KB |
Output is correct |
19 |
Correct |
1 ms |
1620 KB |
Output is correct |
20 |
Correct |
2 ms |
1620 KB |
Output is correct |
21 |
Correct |
6 ms |
2388 KB |
Output is correct |
22 |
Correct |
7 ms |
2516 KB |
Output is correct |
23 |
Correct |
8 ms |
9044 KB |
Output is correct |
24 |
Correct |
13 ms |
12760 KB |
Output is correct |
25 |
Correct |
1 ms |
1620 KB |
Output is correct |
26 |
Correct |
1 ms |
1684 KB |
Output is correct |
27 |
Correct |
15 ms |
13672 KB |
Output is correct |
28 |
Correct |
14 ms |
10520 KB |
Output is correct |
29 |
Correct |
9 ms |
4308 KB |
Output is correct |
30 |
Correct |
12 ms |
8916 KB |
Output is correct |
31 |
Correct |
11 ms |
6356 KB |
Output is correct |
32 |
Correct |
8 ms |
2388 KB |
Output is correct |
33 |
Correct |
9 ms |
2564 KB |
Output is correct |
34 |
Correct |
13 ms |
4788 KB |
Output is correct |
35 |
Correct |
8 ms |
3284 KB |
Output is correct |
36 |
Correct |
12 ms |
3684 KB |
Output is correct |
37 |
Correct |
1 ms |
1620 KB |
Output is correct |
38 |
Correct |
2 ms |
1624 KB |
Output is correct |
39 |
Incorrect |
1 ms |
1620 KB |
Output isn't correct |
40 |
Halted |
0 ms |
0 KB |
- |