#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
using namespace std;
int N, M, Q;
deque<pll> v[2005];
signed main()
{
ios::sync_with_stdio(0), cin.tie(0);
cin >> N >> M >> Q;
for (int i = 1; i <= Q; i++)
{
ll T, L, R, C, K;
cin >> T >> L >> R;
if (T == 1)
{
cin >> C >> K;
for (int j = L; j <= R; j++)
v[j].emplace_back(pll{K, C});
}
else if (T == 2)
{
cin >> K;
for (int j = L; j <= R; j++)
{
ll rem = K;
while (!v[j].empty() && rem > 0)
{
if (v[j].front().F > rem)
{
v[j].front().F -= K;
rem = 0;
}
else if (v[j].front().F <= rem)
{
rem -= v[j].front().F;
v[j].pop_front();
}
}
}
}
else if(T == 3)
{
ll rem = R, ans = 0;
for(auto [cnt, c] : v[L])
{
if(rem <= cnt)
{
ans = c;
break;
}
else
rem -= cnt;
}
cout << ans << '\n';
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2268 KB |
Output is correct |
2 |
Correct |
11 ms |
2540 KB |
Output is correct |
3 |
Correct |
18 ms |
9112 KB |
Output is correct |
4 |
Correct |
27 ms |
12632 KB |
Output is correct |
5 |
Correct |
3 ms |
1620 KB |
Output is correct |
6 |
Correct |
3 ms |
1620 KB |
Output is correct |
7 |
Correct |
21 ms |
14296 KB |
Output is correct |
8 |
Correct |
17 ms |
9848 KB |
Output is correct |
9 |
Correct |
14 ms |
2516 KB |
Output is correct |
10 |
Correct |
17 ms |
9292 KB |
Output is correct |
11 |
Correct |
18 ms |
6408 KB |
Output is correct |
12 |
Correct |
9 ms |
2644 KB |
Output is correct |
13 |
Correct |
11 ms |
2612 KB |
Output is correct |
14 |
Correct |
19 ms |
3756 KB |
Output is correct |
15 |
Correct |
11 ms |
4564 KB |
Output is correct |
16 |
Correct |
16 ms |
3624 KB |
Output is correct |
17 |
Correct |
5 ms |
2004 KB |
Output is correct |
18 |
Correct |
8 ms |
2132 KB |
Output is correct |
19 |
Correct |
2 ms |
1688 KB |
Output is correct |
20 |
Correct |
3 ms |
1620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2268 KB |
Output is correct |
2 |
Correct |
11 ms |
2540 KB |
Output is correct |
3 |
Correct |
18 ms |
9112 KB |
Output is correct |
4 |
Correct |
27 ms |
12632 KB |
Output is correct |
5 |
Correct |
3 ms |
1620 KB |
Output is correct |
6 |
Correct |
3 ms |
1620 KB |
Output is correct |
7 |
Correct |
21 ms |
14296 KB |
Output is correct |
8 |
Correct |
17 ms |
9848 KB |
Output is correct |
9 |
Correct |
14 ms |
2516 KB |
Output is correct |
10 |
Correct |
17 ms |
9292 KB |
Output is correct |
11 |
Correct |
18 ms |
6408 KB |
Output is correct |
12 |
Correct |
9 ms |
2644 KB |
Output is correct |
13 |
Correct |
11 ms |
2612 KB |
Output is correct |
14 |
Correct |
19 ms |
3756 KB |
Output is correct |
15 |
Correct |
11 ms |
4564 KB |
Output is correct |
16 |
Correct |
16 ms |
3624 KB |
Output is correct |
17 |
Correct |
5 ms |
2004 KB |
Output is correct |
18 |
Correct |
8 ms |
2132 KB |
Output is correct |
19 |
Correct |
2 ms |
1688 KB |
Output is correct |
20 |
Correct |
3 ms |
1620 KB |
Output is correct |
21 |
Incorrect |
7 ms |
2132 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
3156 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
3140 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2268 KB |
Output is correct |
2 |
Correct |
11 ms |
2540 KB |
Output is correct |
3 |
Correct |
18 ms |
9112 KB |
Output is correct |
4 |
Correct |
27 ms |
12632 KB |
Output is correct |
5 |
Correct |
3 ms |
1620 KB |
Output is correct |
6 |
Correct |
3 ms |
1620 KB |
Output is correct |
7 |
Correct |
21 ms |
14296 KB |
Output is correct |
8 |
Correct |
17 ms |
9848 KB |
Output is correct |
9 |
Correct |
14 ms |
2516 KB |
Output is correct |
10 |
Correct |
17 ms |
9292 KB |
Output is correct |
11 |
Correct |
18 ms |
6408 KB |
Output is correct |
12 |
Correct |
9 ms |
2644 KB |
Output is correct |
13 |
Correct |
11 ms |
2612 KB |
Output is correct |
14 |
Correct |
19 ms |
3756 KB |
Output is correct |
15 |
Correct |
11 ms |
4564 KB |
Output is correct |
16 |
Correct |
16 ms |
3624 KB |
Output is correct |
17 |
Correct |
5 ms |
2004 KB |
Output is correct |
18 |
Correct |
8 ms |
2132 KB |
Output is correct |
19 |
Correct |
2 ms |
1688 KB |
Output is correct |
20 |
Correct |
3 ms |
1620 KB |
Output is correct |
21 |
Runtime error |
4 ms |
3156 KB |
Execution killed with signal 11 |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
3156 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2268 KB |
Output is correct |
2 |
Correct |
11 ms |
2540 KB |
Output is correct |
3 |
Correct |
18 ms |
9112 KB |
Output is correct |
4 |
Correct |
27 ms |
12632 KB |
Output is correct |
5 |
Correct |
3 ms |
1620 KB |
Output is correct |
6 |
Correct |
3 ms |
1620 KB |
Output is correct |
7 |
Correct |
21 ms |
14296 KB |
Output is correct |
8 |
Correct |
17 ms |
9848 KB |
Output is correct |
9 |
Correct |
14 ms |
2516 KB |
Output is correct |
10 |
Correct |
17 ms |
9292 KB |
Output is correct |
11 |
Correct |
18 ms |
6408 KB |
Output is correct |
12 |
Correct |
9 ms |
2644 KB |
Output is correct |
13 |
Correct |
11 ms |
2612 KB |
Output is correct |
14 |
Correct |
19 ms |
3756 KB |
Output is correct |
15 |
Correct |
11 ms |
4564 KB |
Output is correct |
16 |
Correct |
16 ms |
3624 KB |
Output is correct |
17 |
Correct |
5 ms |
2004 KB |
Output is correct |
18 |
Correct |
8 ms |
2132 KB |
Output is correct |
19 |
Correct |
2 ms |
1688 KB |
Output is correct |
20 |
Correct |
3 ms |
1620 KB |
Output is correct |
21 |
Incorrect |
7 ms |
2132 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2268 KB |
Output is correct |
2 |
Correct |
11 ms |
2540 KB |
Output is correct |
3 |
Correct |
18 ms |
9112 KB |
Output is correct |
4 |
Correct |
27 ms |
12632 KB |
Output is correct |
5 |
Correct |
3 ms |
1620 KB |
Output is correct |
6 |
Correct |
3 ms |
1620 KB |
Output is correct |
7 |
Correct |
21 ms |
14296 KB |
Output is correct |
8 |
Correct |
17 ms |
9848 KB |
Output is correct |
9 |
Correct |
14 ms |
2516 KB |
Output is correct |
10 |
Correct |
17 ms |
9292 KB |
Output is correct |
11 |
Correct |
18 ms |
6408 KB |
Output is correct |
12 |
Correct |
9 ms |
2644 KB |
Output is correct |
13 |
Correct |
11 ms |
2612 KB |
Output is correct |
14 |
Correct |
19 ms |
3756 KB |
Output is correct |
15 |
Correct |
11 ms |
4564 KB |
Output is correct |
16 |
Correct |
16 ms |
3624 KB |
Output is correct |
17 |
Correct |
5 ms |
2004 KB |
Output is correct |
18 |
Correct |
8 ms |
2132 KB |
Output is correct |
19 |
Correct |
2 ms |
1688 KB |
Output is correct |
20 |
Correct |
3 ms |
1620 KB |
Output is correct |
21 |
Incorrect |
7 ms |
2132 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |