#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std ;
const int N = 25e4 ;
ll n, m, q ;
deque<pair<ll, ll>> d[N + 1] ;
signed main()
{
ios_base::sync_with_stdio( 0 ) ;
cin.tie( 0 ) ;
cout.tie( 0 ) ;
cin >> n >> m >> q ;
while(q--)
{
ll type, l, r, c, k, a, b ;
cin >> type ;
if(type == 1)
{
cin >> l >> r >> c >> k ;
for(ll i = l ; i <= r ; i++)
d[i].push_back({c, k}) ;
}
if(type == 2)
{
cin >> l >> r >> k ;
for(ll i = l ; i <= r ; i++)
{
ll sum = 0, k1 = k ;
for(auto j : d[i])
sum += j.se ;
if(sum < k1)
{
d[i].clear() ;
continue ;
}
while(k1)
if(d[i][0].se <= k1)
{
k1 -= d[i][0].se ;
d[i].pop_front() ;
}
else
{
pair<ll, ll> p = {d[i][0].fi, d[i][0].se - k1} ;
d[i].pop_front() ;
d[i].push_front(p) ;
k1 = 0 ;
}
}
}
// for(int i = 1 ; i <= n ; i++)
// {
// cout << i << '\n' ;
// for(auto j : d[i])
// cout << j.fi << ' ' << j.se << '\n' ;
// }
// cout << "__________________\n" ;
if(type == 3)
{
ll sum = 0, ans = 0 ;
cin >> a >> b ;
for(auto i : d[a])
sum += i.se ;
if(sum < b)
{
cout << "0\n" ;
continue ;
}
for(auto i : d[a])
if(i.se < b)
b -= i.se ;
else
{
ans = i.fi ;
break ;
}
cout << ans << "\n" ;
}
}
return 0 ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
109 ms |
169040 KB |
Output is correct |
2 |
Correct |
108 ms |
169292 KB |
Output is correct |
3 |
Correct |
159 ms |
176028 KB |
Output is correct |
4 |
Correct |
210 ms |
179584 KB |
Output is correct |
5 |
Correct |
99 ms |
168600 KB |
Output is correct |
6 |
Correct |
108 ms |
168600 KB |
Output is correct |
7 |
Correct |
280 ms |
181172 KB |
Output is correct |
8 |
Correct |
221 ms |
176756 KB |
Output is correct |
9 |
Correct |
128 ms |
169424 KB |
Output is correct |
10 |
Correct |
206 ms |
176216 KB |
Output is correct |
11 |
Correct |
205 ms |
173484 KB |
Output is correct |
12 |
Correct |
180 ms |
169540 KB |
Output is correct |
13 |
Correct |
133 ms |
169532 KB |
Output is correct |
14 |
Correct |
130 ms |
170664 KB |
Output is correct |
15 |
Correct |
138 ms |
171572 KB |
Output is correct |
16 |
Correct |
127 ms |
170648 KB |
Output is correct |
17 |
Correct |
136 ms |
168952 KB |
Output is correct |
18 |
Correct |
150 ms |
169108 KB |
Output is correct |
19 |
Correct |
107 ms |
168604 KB |
Output is correct |
20 |
Correct |
91 ms |
168548 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
109 ms |
169040 KB |
Output is correct |
2 |
Correct |
108 ms |
169292 KB |
Output is correct |
3 |
Correct |
159 ms |
176028 KB |
Output is correct |
4 |
Correct |
210 ms |
179584 KB |
Output is correct |
5 |
Correct |
99 ms |
168600 KB |
Output is correct |
6 |
Correct |
108 ms |
168600 KB |
Output is correct |
7 |
Correct |
280 ms |
181172 KB |
Output is correct |
8 |
Correct |
221 ms |
176756 KB |
Output is correct |
9 |
Correct |
128 ms |
169424 KB |
Output is correct |
10 |
Correct |
206 ms |
176216 KB |
Output is correct |
11 |
Correct |
205 ms |
173484 KB |
Output is correct |
12 |
Correct |
180 ms |
169540 KB |
Output is correct |
13 |
Correct |
133 ms |
169532 KB |
Output is correct |
14 |
Correct |
130 ms |
170664 KB |
Output is correct |
15 |
Correct |
138 ms |
171572 KB |
Output is correct |
16 |
Correct |
127 ms |
170648 KB |
Output is correct |
17 |
Correct |
136 ms |
168952 KB |
Output is correct |
18 |
Correct |
150 ms |
169108 KB |
Output is correct |
19 |
Correct |
107 ms |
168604 KB |
Output is correct |
20 |
Correct |
91 ms |
168548 KB |
Output is correct |
21 |
Correct |
150 ms |
169272 KB |
Output is correct |
22 |
Correct |
158 ms |
169452 KB |
Output is correct |
23 |
Correct |
189 ms |
175924 KB |
Output is correct |
24 |
Correct |
169 ms |
179660 KB |
Output is correct |
25 |
Correct |
79 ms |
168600 KB |
Output is correct |
26 |
Correct |
86 ms |
168576 KB |
Output is correct |
27 |
Correct |
243 ms |
180548 KB |
Output is correct |
28 |
Correct |
210 ms |
177504 KB |
Output is correct |
29 |
Correct |
141 ms |
171240 KB |
Output is correct |
30 |
Correct |
197 ms |
175820 KB |
Output is correct |
31 |
Correct |
164 ms |
173192 KB |
Output is correct |
32 |
Correct |
133 ms |
169360 KB |
Output is correct |
33 |
Correct |
100 ms |
169448 KB |
Output is correct |
34 |
Correct |
144 ms |
171656 KB |
Output is correct |
35 |
Correct |
123 ms |
170164 KB |
Output is correct |
36 |
Correct |
121 ms |
170644 KB |
Output is correct |
37 |
Correct |
84 ms |
168608 KB |
Output is correct |
38 |
Correct |
86 ms |
168524 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1074 ms |
168624 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1089 ms |
253004 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
109 ms |
169040 KB |
Output is correct |
2 |
Correct |
108 ms |
169292 KB |
Output is correct |
3 |
Correct |
159 ms |
176028 KB |
Output is correct |
4 |
Correct |
210 ms |
179584 KB |
Output is correct |
5 |
Correct |
99 ms |
168600 KB |
Output is correct |
6 |
Correct |
108 ms |
168600 KB |
Output is correct |
7 |
Correct |
280 ms |
181172 KB |
Output is correct |
8 |
Correct |
221 ms |
176756 KB |
Output is correct |
9 |
Correct |
128 ms |
169424 KB |
Output is correct |
10 |
Correct |
206 ms |
176216 KB |
Output is correct |
11 |
Correct |
205 ms |
173484 KB |
Output is correct |
12 |
Correct |
180 ms |
169540 KB |
Output is correct |
13 |
Correct |
133 ms |
169532 KB |
Output is correct |
14 |
Correct |
130 ms |
170664 KB |
Output is correct |
15 |
Correct |
138 ms |
171572 KB |
Output is correct |
16 |
Correct |
127 ms |
170648 KB |
Output is correct |
17 |
Correct |
136 ms |
168952 KB |
Output is correct |
18 |
Correct |
150 ms |
169108 KB |
Output is correct |
19 |
Correct |
107 ms |
168604 KB |
Output is correct |
20 |
Correct |
91 ms |
168548 KB |
Output is correct |
21 |
Execution timed out |
1074 ms |
168624 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
382 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
109 ms |
169040 KB |
Output is correct |
2 |
Correct |
108 ms |
169292 KB |
Output is correct |
3 |
Correct |
159 ms |
176028 KB |
Output is correct |
4 |
Correct |
210 ms |
179584 KB |
Output is correct |
5 |
Correct |
99 ms |
168600 KB |
Output is correct |
6 |
Correct |
108 ms |
168600 KB |
Output is correct |
7 |
Correct |
280 ms |
181172 KB |
Output is correct |
8 |
Correct |
221 ms |
176756 KB |
Output is correct |
9 |
Correct |
128 ms |
169424 KB |
Output is correct |
10 |
Correct |
206 ms |
176216 KB |
Output is correct |
11 |
Correct |
205 ms |
173484 KB |
Output is correct |
12 |
Correct |
180 ms |
169540 KB |
Output is correct |
13 |
Correct |
133 ms |
169532 KB |
Output is correct |
14 |
Correct |
130 ms |
170664 KB |
Output is correct |
15 |
Correct |
138 ms |
171572 KB |
Output is correct |
16 |
Correct |
127 ms |
170648 KB |
Output is correct |
17 |
Correct |
136 ms |
168952 KB |
Output is correct |
18 |
Correct |
150 ms |
169108 KB |
Output is correct |
19 |
Correct |
107 ms |
168604 KB |
Output is correct |
20 |
Correct |
91 ms |
168548 KB |
Output is correct |
21 |
Correct |
150 ms |
169272 KB |
Output is correct |
22 |
Correct |
158 ms |
169452 KB |
Output is correct |
23 |
Correct |
189 ms |
175924 KB |
Output is correct |
24 |
Correct |
169 ms |
179660 KB |
Output is correct |
25 |
Correct |
79 ms |
168600 KB |
Output is correct |
26 |
Correct |
86 ms |
168576 KB |
Output is correct |
27 |
Correct |
243 ms |
180548 KB |
Output is correct |
28 |
Correct |
210 ms |
177504 KB |
Output is correct |
29 |
Correct |
141 ms |
171240 KB |
Output is correct |
30 |
Correct |
197 ms |
175820 KB |
Output is correct |
31 |
Correct |
164 ms |
173192 KB |
Output is correct |
32 |
Correct |
133 ms |
169360 KB |
Output is correct |
33 |
Correct |
100 ms |
169448 KB |
Output is correct |
34 |
Correct |
144 ms |
171656 KB |
Output is correct |
35 |
Correct |
123 ms |
170164 KB |
Output is correct |
36 |
Correct |
121 ms |
170644 KB |
Output is correct |
37 |
Correct |
84 ms |
168608 KB |
Output is correct |
38 |
Correct |
86 ms |
168524 KB |
Output is correct |
39 |
Execution timed out |
1074 ms |
168624 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
109 ms |
169040 KB |
Output is correct |
2 |
Correct |
108 ms |
169292 KB |
Output is correct |
3 |
Correct |
159 ms |
176028 KB |
Output is correct |
4 |
Correct |
210 ms |
179584 KB |
Output is correct |
5 |
Correct |
99 ms |
168600 KB |
Output is correct |
6 |
Correct |
108 ms |
168600 KB |
Output is correct |
7 |
Correct |
280 ms |
181172 KB |
Output is correct |
8 |
Correct |
221 ms |
176756 KB |
Output is correct |
9 |
Correct |
128 ms |
169424 KB |
Output is correct |
10 |
Correct |
206 ms |
176216 KB |
Output is correct |
11 |
Correct |
205 ms |
173484 KB |
Output is correct |
12 |
Correct |
180 ms |
169540 KB |
Output is correct |
13 |
Correct |
133 ms |
169532 KB |
Output is correct |
14 |
Correct |
130 ms |
170664 KB |
Output is correct |
15 |
Correct |
138 ms |
171572 KB |
Output is correct |
16 |
Correct |
127 ms |
170648 KB |
Output is correct |
17 |
Correct |
136 ms |
168952 KB |
Output is correct |
18 |
Correct |
150 ms |
169108 KB |
Output is correct |
19 |
Correct |
107 ms |
168604 KB |
Output is correct |
20 |
Correct |
91 ms |
168548 KB |
Output is correct |
21 |
Correct |
150 ms |
169272 KB |
Output is correct |
22 |
Correct |
158 ms |
169452 KB |
Output is correct |
23 |
Correct |
189 ms |
175924 KB |
Output is correct |
24 |
Correct |
169 ms |
179660 KB |
Output is correct |
25 |
Correct |
79 ms |
168600 KB |
Output is correct |
26 |
Correct |
86 ms |
168576 KB |
Output is correct |
27 |
Correct |
243 ms |
180548 KB |
Output is correct |
28 |
Correct |
210 ms |
177504 KB |
Output is correct |
29 |
Correct |
141 ms |
171240 KB |
Output is correct |
30 |
Correct |
197 ms |
175820 KB |
Output is correct |
31 |
Correct |
164 ms |
173192 KB |
Output is correct |
32 |
Correct |
133 ms |
169360 KB |
Output is correct |
33 |
Correct |
100 ms |
169448 KB |
Output is correct |
34 |
Correct |
144 ms |
171656 KB |
Output is correct |
35 |
Correct |
123 ms |
170164 KB |
Output is correct |
36 |
Correct |
121 ms |
170644 KB |
Output is correct |
37 |
Correct |
84 ms |
168608 KB |
Output is correct |
38 |
Correct |
86 ms |
168524 KB |
Output is correct |
39 |
Execution timed out |
1074 ms |
168624 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |