#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
typedef long long ll;
const int mxN = 250005;
const int mxM = 250005;
const int mxQ = 250005;
int N, M, Q;
int group[mxM];
struct Data { int L, R, C; ll K; };
vector<Data> stuff;
int main() {
ios::sync_with_stdio(0); cin.tie(0);
cin >> N >> M >> Q;
FOR(i,1,Q){
int T, L, R, C, K, A;
long long B;
cin >> T;
if (T == 1) {
cin >> L >> R >> C >> K;
stuff.push_back({L,R,C,K});
} else if (T == 2) {
cin >> L >> R >> K;
stuff.push_back({L,R,-1,K});
} else {
cin >> A >> B;
stuff.push_back({ A,A,-1,B-1 });
queue<pair<int,ll>> q;
for (auto& x : stuff) if (x.L <= A && A <= x.R) {
if (x.C == -1) {
ll del = x.K;
while (!q.empty() && del) {
auto& u = q.front();
if (u.second <= del) {
del -= u.second;
q.pop();
} else {
u.second -= del;
del = 0;
}
}
} else {
q.push(make_pair(x.C,x.K));
}
}
stuff.pop_back();
if (q.empty()) cout << 0 << '\n';
else cout << q.front().first << '\n';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
332 KB |
Output is correct |
2 |
Correct |
4 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
4 ms |
332 KB |
Output is correct |
5 |
Correct |
3 ms |
332 KB |
Output is correct |
6 |
Correct |
3 ms |
332 KB |
Output is correct |
7 |
Correct |
4 ms |
332 KB |
Output is correct |
8 |
Correct |
4 ms |
332 KB |
Output is correct |
9 |
Correct |
4 ms |
416 KB |
Output is correct |
10 |
Correct |
5 ms |
408 KB |
Output is correct |
11 |
Correct |
6 ms |
332 KB |
Output is correct |
12 |
Correct |
4 ms |
332 KB |
Output is correct |
13 |
Correct |
3 ms |
332 KB |
Output is correct |
14 |
Correct |
3 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
5 ms |
332 KB |
Output is correct |
17 |
Correct |
3 ms |
332 KB |
Output is correct |
18 |
Correct |
4 ms |
364 KB |
Output is correct |
19 |
Correct |
2 ms |
332 KB |
Output is correct |
20 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
332 KB |
Output is correct |
2 |
Correct |
4 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
4 ms |
332 KB |
Output is correct |
5 |
Correct |
3 ms |
332 KB |
Output is correct |
6 |
Correct |
3 ms |
332 KB |
Output is correct |
7 |
Correct |
4 ms |
332 KB |
Output is correct |
8 |
Correct |
4 ms |
332 KB |
Output is correct |
9 |
Correct |
4 ms |
416 KB |
Output is correct |
10 |
Correct |
5 ms |
408 KB |
Output is correct |
11 |
Correct |
6 ms |
332 KB |
Output is correct |
12 |
Correct |
4 ms |
332 KB |
Output is correct |
13 |
Correct |
3 ms |
332 KB |
Output is correct |
14 |
Correct |
3 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
5 ms |
332 KB |
Output is correct |
17 |
Correct |
3 ms |
332 KB |
Output is correct |
18 |
Correct |
4 ms |
364 KB |
Output is correct |
19 |
Correct |
2 ms |
332 KB |
Output is correct |
20 |
Correct |
2 ms |
332 KB |
Output is correct |
21 |
Correct |
5 ms |
332 KB |
Output is correct |
22 |
Correct |
6 ms |
332 KB |
Output is correct |
23 |
Correct |
4 ms |
332 KB |
Output is correct |
24 |
Correct |
7 ms |
332 KB |
Output is correct |
25 |
Correct |
3 ms |
364 KB |
Output is correct |
26 |
Correct |
4 ms |
332 KB |
Output is correct |
27 |
Correct |
5 ms |
332 KB |
Output is correct |
28 |
Correct |
4 ms |
332 KB |
Output is correct |
29 |
Correct |
5 ms |
332 KB |
Output is correct |
30 |
Correct |
5 ms |
332 KB |
Output is correct |
31 |
Correct |
5 ms |
332 KB |
Output is correct |
32 |
Correct |
5 ms |
332 KB |
Output is correct |
33 |
Correct |
3 ms |
332 KB |
Output is correct |
34 |
Correct |
4 ms |
332 KB |
Output is correct |
35 |
Correct |
3 ms |
332 KB |
Output is correct |
36 |
Correct |
7 ms |
332 KB |
Output is correct |
37 |
Correct |
2 ms |
332 KB |
Output is correct |
38 |
Correct |
3 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1078 ms |
1232 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1071 ms |
1224 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
332 KB |
Output is correct |
2 |
Correct |
4 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
4 ms |
332 KB |
Output is correct |
5 |
Correct |
3 ms |
332 KB |
Output is correct |
6 |
Correct |
3 ms |
332 KB |
Output is correct |
7 |
Correct |
4 ms |
332 KB |
Output is correct |
8 |
Correct |
4 ms |
332 KB |
Output is correct |
9 |
Correct |
4 ms |
416 KB |
Output is correct |
10 |
Correct |
5 ms |
408 KB |
Output is correct |
11 |
Correct |
6 ms |
332 KB |
Output is correct |
12 |
Correct |
4 ms |
332 KB |
Output is correct |
13 |
Correct |
3 ms |
332 KB |
Output is correct |
14 |
Correct |
3 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
5 ms |
332 KB |
Output is correct |
17 |
Correct |
3 ms |
332 KB |
Output is correct |
18 |
Correct |
4 ms |
364 KB |
Output is correct |
19 |
Correct |
2 ms |
332 KB |
Output is correct |
20 |
Correct |
2 ms |
332 KB |
Output is correct |
21 |
Execution timed out |
1078 ms |
1232 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1063 ms |
1340 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
332 KB |
Output is correct |
2 |
Correct |
4 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
4 ms |
332 KB |
Output is correct |
5 |
Correct |
3 ms |
332 KB |
Output is correct |
6 |
Correct |
3 ms |
332 KB |
Output is correct |
7 |
Correct |
4 ms |
332 KB |
Output is correct |
8 |
Correct |
4 ms |
332 KB |
Output is correct |
9 |
Correct |
4 ms |
416 KB |
Output is correct |
10 |
Correct |
5 ms |
408 KB |
Output is correct |
11 |
Correct |
6 ms |
332 KB |
Output is correct |
12 |
Correct |
4 ms |
332 KB |
Output is correct |
13 |
Correct |
3 ms |
332 KB |
Output is correct |
14 |
Correct |
3 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
5 ms |
332 KB |
Output is correct |
17 |
Correct |
3 ms |
332 KB |
Output is correct |
18 |
Correct |
4 ms |
364 KB |
Output is correct |
19 |
Correct |
2 ms |
332 KB |
Output is correct |
20 |
Correct |
2 ms |
332 KB |
Output is correct |
21 |
Correct |
5 ms |
332 KB |
Output is correct |
22 |
Correct |
6 ms |
332 KB |
Output is correct |
23 |
Correct |
4 ms |
332 KB |
Output is correct |
24 |
Correct |
7 ms |
332 KB |
Output is correct |
25 |
Correct |
3 ms |
364 KB |
Output is correct |
26 |
Correct |
4 ms |
332 KB |
Output is correct |
27 |
Correct |
5 ms |
332 KB |
Output is correct |
28 |
Correct |
4 ms |
332 KB |
Output is correct |
29 |
Correct |
5 ms |
332 KB |
Output is correct |
30 |
Correct |
5 ms |
332 KB |
Output is correct |
31 |
Correct |
5 ms |
332 KB |
Output is correct |
32 |
Correct |
5 ms |
332 KB |
Output is correct |
33 |
Correct |
3 ms |
332 KB |
Output is correct |
34 |
Correct |
4 ms |
332 KB |
Output is correct |
35 |
Correct |
3 ms |
332 KB |
Output is correct |
36 |
Correct |
7 ms |
332 KB |
Output is correct |
37 |
Correct |
2 ms |
332 KB |
Output is correct |
38 |
Correct |
3 ms |
332 KB |
Output is correct |
39 |
Execution timed out |
1078 ms |
1232 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
332 KB |
Output is correct |
2 |
Correct |
4 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
4 ms |
332 KB |
Output is correct |
5 |
Correct |
3 ms |
332 KB |
Output is correct |
6 |
Correct |
3 ms |
332 KB |
Output is correct |
7 |
Correct |
4 ms |
332 KB |
Output is correct |
8 |
Correct |
4 ms |
332 KB |
Output is correct |
9 |
Correct |
4 ms |
416 KB |
Output is correct |
10 |
Correct |
5 ms |
408 KB |
Output is correct |
11 |
Correct |
6 ms |
332 KB |
Output is correct |
12 |
Correct |
4 ms |
332 KB |
Output is correct |
13 |
Correct |
3 ms |
332 KB |
Output is correct |
14 |
Correct |
3 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
5 ms |
332 KB |
Output is correct |
17 |
Correct |
3 ms |
332 KB |
Output is correct |
18 |
Correct |
4 ms |
364 KB |
Output is correct |
19 |
Correct |
2 ms |
332 KB |
Output is correct |
20 |
Correct |
2 ms |
332 KB |
Output is correct |
21 |
Correct |
5 ms |
332 KB |
Output is correct |
22 |
Correct |
6 ms |
332 KB |
Output is correct |
23 |
Correct |
4 ms |
332 KB |
Output is correct |
24 |
Correct |
7 ms |
332 KB |
Output is correct |
25 |
Correct |
3 ms |
364 KB |
Output is correct |
26 |
Correct |
4 ms |
332 KB |
Output is correct |
27 |
Correct |
5 ms |
332 KB |
Output is correct |
28 |
Correct |
4 ms |
332 KB |
Output is correct |
29 |
Correct |
5 ms |
332 KB |
Output is correct |
30 |
Correct |
5 ms |
332 KB |
Output is correct |
31 |
Correct |
5 ms |
332 KB |
Output is correct |
32 |
Correct |
5 ms |
332 KB |
Output is correct |
33 |
Correct |
3 ms |
332 KB |
Output is correct |
34 |
Correct |
4 ms |
332 KB |
Output is correct |
35 |
Correct |
3 ms |
332 KB |
Output is correct |
36 |
Correct |
7 ms |
332 KB |
Output is correct |
37 |
Correct |
2 ms |
332 KB |
Output is correct |
38 |
Correct |
3 ms |
332 KB |
Output is correct |
39 |
Execution timed out |
1078 ms |
1232 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |