#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
const int mxN = 70000;
int n, m, q, tot[mxN], del[mxN];
deque<array<int,2>> shop[mxN];
void add(int i, int x, int v){
if(sz(shop[i]) and shop[i].back()[0]==x) shop[i].back()[1]+=v,tot[i]+=v;
else shop[i].pb({x,v+(sz(shop[i])?shop[i].back()[1]:0)}),tot[i]+=v;
}
void rem(int i, int v){
if(tot[i]<=v) del[i]+=tot[i], tot[i]=0;
else del[i]+=v, tot[i]-=v;
}
int get(int i, int v){
v+=del[i]; if(!sz(shop[i]) or shop[i].back()[1]<v) return 0;
int l = 0, r = sz(shop[i])-1;
while(l<r){
int mid = (l+r)/2;
if(shop[i][mid][1]<v) l=mid+1;
else r=mid;
}
return shop[i][l][0];
}
int32_t main()
{
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> m >> q;
while(q--){
int t, l, r, x, v;
cin >> t;
if(t==1){
cin >> l >> r >> x >> v;
for(int i = l; i <= r; i++) add(i,x,v);
}
else if(t==2){
cin >> l >> r >> v;
for(int i = l; i <= r; i++) rem(i,v);
}
else cin >> x >> v, cout << get(x,v) << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
51268 KB |
Output is correct |
2 |
Correct |
34 ms |
54432 KB |
Output is correct |
3 |
Correct |
37 ms |
57740 KB |
Output is correct |
4 |
Correct |
44 ms |
63756 KB |
Output is correct |
5 |
Correct |
30 ms |
47428 KB |
Output is correct |
6 |
Correct |
25 ms |
47404 KB |
Output is correct |
7 |
Correct |
41 ms |
59940 KB |
Output is correct |
8 |
Correct |
49 ms |
59868 KB |
Output is correct |
9 |
Correct |
42 ms |
59732 KB |
Output is correct |
10 |
Correct |
41 ms |
59972 KB |
Output is correct |
11 |
Correct |
41 ms |
60236 KB |
Output is correct |
12 |
Correct |
40 ms |
59964 KB |
Output is correct |
13 |
Correct |
43 ms |
63208 KB |
Output is correct |
14 |
Correct |
51 ms |
70104 KB |
Output is correct |
15 |
Correct |
43 ms |
63272 KB |
Output is correct |
16 |
Correct |
62 ms |
69892 KB |
Output is correct |
17 |
Correct |
35 ms |
53312 KB |
Output is correct |
18 |
Correct |
39 ms |
58060 KB |
Output is correct |
19 |
Correct |
25 ms |
47444 KB |
Output is correct |
20 |
Correct |
24 ms |
47444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
51268 KB |
Output is correct |
2 |
Correct |
34 ms |
54432 KB |
Output is correct |
3 |
Correct |
37 ms |
57740 KB |
Output is correct |
4 |
Correct |
44 ms |
63756 KB |
Output is correct |
5 |
Correct |
30 ms |
47428 KB |
Output is correct |
6 |
Correct |
25 ms |
47404 KB |
Output is correct |
7 |
Correct |
41 ms |
59940 KB |
Output is correct |
8 |
Correct |
49 ms |
59868 KB |
Output is correct |
9 |
Correct |
42 ms |
59732 KB |
Output is correct |
10 |
Correct |
41 ms |
59972 KB |
Output is correct |
11 |
Correct |
41 ms |
60236 KB |
Output is correct |
12 |
Correct |
40 ms |
59964 KB |
Output is correct |
13 |
Correct |
43 ms |
63208 KB |
Output is correct |
14 |
Correct |
51 ms |
70104 KB |
Output is correct |
15 |
Correct |
43 ms |
63272 KB |
Output is correct |
16 |
Correct |
62 ms |
69892 KB |
Output is correct |
17 |
Correct |
35 ms |
53312 KB |
Output is correct |
18 |
Correct |
39 ms |
58060 KB |
Output is correct |
19 |
Correct |
25 ms |
47444 KB |
Output is correct |
20 |
Correct |
24 ms |
47444 KB |
Output is correct |
21 |
Correct |
34 ms |
53520 KB |
Output is correct |
22 |
Correct |
36 ms |
54260 KB |
Output is correct |
23 |
Correct |
38 ms |
57828 KB |
Output is correct |
24 |
Correct |
44 ms |
63692 KB |
Output is correct |
25 |
Correct |
24 ms |
47468 KB |
Output is correct |
26 |
Correct |
25 ms |
47404 KB |
Output is correct |
27 |
Correct |
40 ms |
59296 KB |
Output is correct |
28 |
Correct |
42 ms |
60296 KB |
Output is correct |
29 |
Correct |
41 ms |
59608 KB |
Output is correct |
30 |
Correct |
41 ms |
59964 KB |
Output is correct |
31 |
Correct |
45 ms |
59212 KB |
Output is correct |
32 |
Correct |
39 ms |
59012 KB |
Output is correct |
33 |
Correct |
45 ms |
63544 KB |
Output is correct |
34 |
Correct |
51 ms |
70104 KB |
Output is correct |
35 |
Correct |
43 ms |
63048 KB |
Output is correct |
36 |
Correct |
49 ms |
69840 KB |
Output is correct |
37 |
Correct |
26 ms |
47484 KB |
Output is correct |
38 |
Correct |
26 ms |
47480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1004 ms |
48712 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
64 ms |
95932 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
51268 KB |
Output is correct |
2 |
Correct |
34 ms |
54432 KB |
Output is correct |
3 |
Correct |
37 ms |
57740 KB |
Output is correct |
4 |
Correct |
44 ms |
63756 KB |
Output is correct |
5 |
Correct |
30 ms |
47428 KB |
Output is correct |
6 |
Correct |
25 ms |
47404 KB |
Output is correct |
7 |
Correct |
41 ms |
59940 KB |
Output is correct |
8 |
Correct |
49 ms |
59868 KB |
Output is correct |
9 |
Correct |
42 ms |
59732 KB |
Output is correct |
10 |
Correct |
41 ms |
59972 KB |
Output is correct |
11 |
Correct |
41 ms |
60236 KB |
Output is correct |
12 |
Correct |
40 ms |
59964 KB |
Output is correct |
13 |
Correct |
43 ms |
63208 KB |
Output is correct |
14 |
Correct |
51 ms |
70104 KB |
Output is correct |
15 |
Correct |
43 ms |
63272 KB |
Output is correct |
16 |
Correct |
62 ms |
69892 KB |
Output is correct |
17 |
Correct |
35 ms |
53312 KB |
Output is correct |
18 |
Correct |
39 ms |
58060 KB |
Output is correct |
19 |
Correct |
25 ms |
47444 KB |
Output is correct |
20 |
Correct |
24 ms |
47444 KB |
Output is correct |
21 |
Execution timed out |
1004 ms |
48712 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
757 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
51268 KB |
Output is correct |
2 |
Correct |
34 ms |
54432 KB |
Output is correct |
3 |
Correct |
37 ms |
57740 KB |
Output is correct |
4 |
Correct |
44 ms |
63756 KB |
Output is correct |
5 |
Correct |
30 ms |
47428 KB |
Output is correct |
6 |
Correct |
25 ms |
47404 KB |
Output is correct |
7 |
Correct |
41 ms |
59940 KB |
Output is correct |
8 |
Correct |
49 ms |
59868 KB |
Output is correct |
9 |
Correct |
42 ms |
59732 KB |
Output is correct |
10 |
Correct |
41 ms |
59972 KB |
Output is correct |
11 |
Correct |
41 ms |
60236 KB |
Output is correct |
12 |
Correct |
40 ms |
59964 KB |
Output is correct |
13 |
Correct |
43 ms |
63208 KB |
Output is correct |
14 |
Correct |
51 ms |
70104 KB |
Output is correct |
15 |
Correct |
43 ms |
63272 KB |
Output is correct |
16 |
Correct |
62 ms |
69892 KB |
Output is correct |
17 |
Correct |
35 ms |
53312 KB |
Output is correct |
18 |
Correct |
39 ms |
58060 KB |
Output is correct |
19 |
Correct |
25 ms |
47444 KB |
Output is correct |
20 |
Correct |
24 ms |
47444 KB |
Output is correct |
21 |
Correct |
34 ms |
53520 KB |
Output is correct |
22 |
Correct |
36 ms |
54260 KB |
Output is correct |
23 |
Correct |
38 ms |
57828 KB |
Output is correct |
24 |
Correct |
44 ms |
63692 KB |
Output is correct |
25 |
Correct |
24 ms |
47468 KB |
Output is correct |
26 |
Correct |
25 ms |
47404 KB |
Output is correct |
27 |
Correct |
40 ms |
59296 KB |
Output is correct |
28 |
Correct |
42 ms |
60296 KB |
Output is correct |
29 |
Correct |
41 ms |
59608 KB |
Output is correct |
30 |
Correct |
41 ms |
59964 KB |
Output is correct |
31 |
Correct |
45 ms |
59212 KB |
Output is correct |
32 |
Correct |
39 ms |
59012 KB |
Output is correct |
33 |
Correct |
45 ms |
63544 KB |
Output is correct |
34 |
Correct |
51 ms |
70104 KB |
Output is correct |
35 |
Correct |
43 ms |
63048 KB |
Output is correct |
36 |
Correct |
49 ms |
69840 KB |
Output is correct |
37 |
Correct |
26 ms |
47484 KB |
Output is correct |
38 |
Correct |
26 ms |
47480 KB |
Output is correct |
39 |
Execution timed out |
1004 ms |
48712 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
51268 KB |
Output is correct |
2 |
Correct |
34 ms |
54432 KB |
Output is correct |
3 |
Correct |
37 ms |
57740 KB |
Output is correct |
4 |
Correct |
44 ms |
63756 KB |
Output is correct |
5 |
Correct |
30 ms |
47428 KB |
Output is correct |
6 |
Correct |
25 ms |
47404 KB |
Output is correct |
7 |
Correct |
41 ms |
59940 KB |
Output is correct |
8 |
Correct |
49 ms |
59868 KB |
Output is correct |
9 |
Correct |
42 ms |
59732 KB |
Output is correct |
10 |
Correct |
41 ms |
59972 KB |
Output is correct |
11 |
Correct |
41 ms |
60236 KB |
Output is correct |
12 |
Correct |
40 ms |
59964 KB |
Output is correct |
13 |
Correct |
43 ms |
63208 KB |
Output is correct |
14 |
Correct |
51 ms |
70104 KB |
Output is correct |
15 |
Correct |
43 ms |
63272 KB |
Output is correct |
16 |
Correct |
62 ms |
69892 KB |
Output is correct |
17 |
Correct |
35 ms |
53312 KB |
Output is correct |
18 |
Correct |
39 ms |
58060 KB |
Output is correct |
19 |
Correct |
25 ms |
47444 KB |
Output is correct |
20 |
Correct |
24 ms |
47444 KB |
Output is correct |
21 |
Correct |
34 ms |
53520 KB |
Output is correct |
22 |
Correct |
36 ms |
54260 KB |
Output is correct |
23 |
Correct |
38 ms |
57828 KB |
Output is correct |
24 |
Correct |
44 ms |
63692 KB |
Output is correct |
25 |
Correct |
24 ms |
47468 KB |
Output is correct |
26 |
Correct |
25 ms |
47404 KB |
Output is correct |
27 |
Correct |
40 ms |
59296 KB |
Output is correct |
28 |
Correct |
42 ms |
60296 KB |
Output is correct |
29 |
Correct |
41 ms |
59608 KB |
Output is correct |
30 |
Correct |
41 ms |
59964 KB |
Output is correct |
31 |
Correct |
45 ms |
59212 KB |
Output is correct |
32 |
Correct |
39 ms |
59012 KB |
Output is correct |
33 |
Correct |
45 ms |
63544 KB |
Output is correct |
34 |
Correct |
51 ms |
70104 KB |
Output is correct |
35 |
Correct |
43 ms |
63048 KB |
Output is correct |
36 |
Correct |
49 ms |
69840 KB |
Output is correct |
37 |
Correct |
26 ms |
47484 KB |
Output is correct |
38 |
Correct |
26 ms |
47480 KB |
Output is correct |
39 |
Execution timed out |
1004 ms |
48712 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |