/* In the name of God, aka Allah */
// let this be mytemp.cpp
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define endl '\n'
#define mk make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 2.5e5+50;
ll n, m, q, pt[N], sm[N];
vector<pll> vc[N];
void join(int l, int r, int c, ll k) {
for (int i = l; i <= r; i++) {
vc[i].push_back({c, k});
sm[i] += k;
}
}
void leave(int l, int r, ll k) {
for (int i = l; i <= r; i++) {
pt[i] += k;
pt[i] = min(pt[i], sm[i]);
}
}
ll service(int id, ll x) {
ll t = 0;
for (pll p:vc[id]) {
t += p.S;
if (t >= x+pt[id]) return p.F;
}
return 0;
}
void solve() {
cin >> n >> m >> q;
for (int i = 1; i <= q; i++) {
ll t, l, r, c, k, id, x;
cin >> t;
if (t == 1) {
cin >> l >> r >> c >> k;
join(l, r, c, k);
}
if (t == 2) {
cin >> l >> r >> k;
leave(l, r, k);
}
if (t == 3) {
cin >> id >> x;
cout << service(id, x) << endl;
}
}
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
11988 KB |
Output is correct |
2 |
Correct |
15 ms |
17620 KB |
Output is correct |
3 |
Correct |
18 ms |
19504 KB |
Output is correct |
4 |
Correct |
27 ms |
30132 KB |
Output is correct |
5 |
Correct |
3 ms |
6228 KB |
Output is correct |
6 |
Correct |
4 ms |
6228 KB |
Output is correct |
7 |
Correct |
22 ms |
23644 KB |
Output is correct |
8 |
Correct |
21 ms |
23044 KB |
Output is correct |
9 |
Correct |
20 ms |
23124 KB |
Output is correct |
10 |
Correct |
23 ms |
24168 KB |
Output is correct |
11 |
Correct |
23 ms |
24676 KB |
Output is correct |
12 |
Correct |
22 ms |
23716 KB |
Output is correct |
13 |
Correct |
29 ms |
31996 KB |
Output is correct |
14 |
Correct |
35 ms |
37100 KB |
Output is correct |
15 |
Correct |
22 ms |
21808 KB |
Output is correct |
16 |
Correct |
34 ms |
36800 KB |
Output is correct |
17 |
Correct |
12 ms |
15188 KB |
Output is correct |
18 |
Correct |
17 ms |
19928 KB |
Output is correct |
19 |
Correct |
4 ms |
6356 KB |
Output is correct |
20 |
Correct |
4 ms |
6484 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
11988 KB |
Output is correct |
2 |
Correct |
15 ms |
17620 KB |
Output is correct |
3 |
Correct |
18 ms |
19504 KB |
Output is correct |
4 |
Correct |
27 ms |
30132 KB |
Output is correct |
5 |
Correct |
3 ms |
6228 KB |
Output is correct |
6 |
Correct |
4 ms |
6228 KB |
Output is correct |
7 |
Correct |
22 ms |
23644 KB |
Output is correct |
8 |
Correct |
21 ms |
23044 KB |
Output is correct |
9 |
Correct |
20 ms |
23124 KB |
Output is correct |
10 |
Correct |
23 ms |
24168 KB |
Output is correct |
11 |
Correct |
23 ms |
24676 KB |
Output is correct |
12 |
Correct |
22 ms |
23716 KB |
Output is correct |
13 |
Correct |
29 ms |
31996 KB |
Output is correct |
14 |
Correct |
35 ms |
37100 KB |
Output is correct |
15 |
Correct |
22 ms |
21808 KB |
Output is correct |
16 |
Correct |
34 ms |
36800 KB |
Output is correct |
17 |
Correct |
12 ms |
15188 KB |
Output is correct |
18 |
Correct |
17 ms |
19928 KB |
Output is correct |
19 |
Correct |
4 ms |
6356 KB |
Output is correct |
20 |
Correct |
4 ms |
6484 KB |
Output is correct |
21 |
Correct |
13 ms |
16584 KB |
Output is correct |
22 |
Correct |
16 ms |
17676 KB |
Output is correct |
23 |
Correct |
18 ms |
21748 KB |
Output is correct |
24 |
Correct |
27 ms |
30188 KB |
Output is correct |
25 |
Correct |
4 ms |
6228 KB |
Output is correct |
26 |
Correct |
3 ms |
6228 KB |
Output is correct |
27 |
Correct |
20 ms |
21040 KB |
Output is correct |
28 |
Correct |
23 ms |
24064 KB |
Output is correct |
29 |
Correct |
24 ms |
23924 KB |
Output is correct |
30 |
Correct |
22 ms |
23500 KB |
Output is correct |
31 |
Correct |
19 ms |
20476 KB |
Output is correct |
32 |
Correct |
19 ms |
20316 KB |
Output is correct |
33 |
Correct |
27 ms |
30356 KB |
Output is correct |
34 |
Correct |
35 ms |
36960 KB |
Output is correct |
35 |
Correct |
27 ms |
28832 KB |
Output is correct |
36 |
Correct |
35 ms |
36536 KB |
Output is correct |
37 |
Correct |
4 ms |
6356 KB |
Output is correct |
38 |
Correct |
5 ms |
6484 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
416 ms |
10476 KB |
Output is correct |
2 |
Correct |
341 ms |
12188 KB |
Output is correct |
3 |
Correct |
431 ms |
13220 KB |
Output is correct |
4 |
Correct |
460 ms |
13400 KB |
Output is correct |
5 |
Correct |
337 ms |
16248 KB |
Output is correct |
6 |
Correct |
371 ms |
16168 KB |
Output is correct |
7 |
Correct |
150 ms |
6888 KB |
Output is correct |
8 |
Correct |
168 ms |
7088 KB |
Output is correct |
9 |
Correct |
706 ms |
10976 KB |
Output is correct |
10 |
Correct |
737 ms |
12188 KB |
Output is correct |
11 |
Correct |
689 ms |
12236 KB |
Output is correct |
12 |
Correct |
742 ms |
12192 KB |
Output is correct |
13 |
Correct |
139 ms |
13360 KB |
Output is correct |
14 |
Correct |
226 ms |
14496 KB |
Output is correct |
15 |
Correct |
59 ms |
16972 KB |
Output is correct |
16 |
Correct |
69 ms |
17328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
828 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
11988 KB |
Output is correct |
2 |
Correct |
15 ms |
17620 KB |
Output is correct |
3 |
Correct |
18 ms |
19504 KB |
Output is correct |
4 |
Correct |
27 ms |
30132 KB |
Output is correct |
5 |
Correct |
3 ms |
6228 KB |
Output is correct |
6 |
Correct |
4 ms |
6228 KB |
Output is correct |
7 |
Correct |
22 ms |
23644 KB |
Output is correct |
8 |
Correct |
21 ms |
23044 KB |
Output is correct |
9 |
Correct |
20 ms |
23124 KB |
Output is correct |
10 |
Correct |
23 ms |
24168 KB |
Output is correct |
11 |
Correct |
23 ms |
24676 KB |
Output is correct |
12 |
Correct |
22 ms |
23716 KB |
Output is correct |
13 |
Correct |
29 ms |
31996 KB |
Output is correct |
14 |
Correct |
35 ms |
37100 KB |
Output is correct |
15 |
Correct |
22 ms |
21808 KB |
Output is correct |
16 |
Correct |
34 ms |
36800 KB |
Output is correct |
17 |
Correct |
12 ms |
15188 KB |
Output is correct |
18 |
Correct |
17 ms |
19928 KB |
Output is correct |
19 |
Correct |
4 ms |
6356 KB |
Output is correct |
20 |
Correct |
4 ms |
6484 KB |
Output is correct |
21 |
Correct |
416 ms |
10476 KB |
Output is correct |
22 |
Correct |
341 ms |
12188 KB |
Output is correct |
23 |
Correct |
431 ms |
13220 KB |
Output is correct |
24 |
Correct |
460 ms |
13400 KB |
Output is correct |
25 |
Correct |
337 ms |
16248 KB |
Output is correct |
26 |
Correct |
371 ms |
16168 KB |
Output is correct |
27 |
Correct |
150 ms |
6888 KB |
Output is correct |
28 |
Correct |
168 ms |
7088 KB |
Output is correct |
29 |
Correct |
706 ms |
10976 KB |
Output is correct |
30 |
Correct |
737 ms |
12188 KB |
Output is correct |
31 |
Correct |
689 ms |
12236 KB |
Output is correct |
32 |
Correct |
742 ms |
12192 KB |
Output is correct |
33 |
Correct |
139 ms |
13360 KB |
Output is correct |
34 |
Correct |
226 ms |
14496 KB |
Output is correct |
35 |
Correct |
59 ms |
16972 KB |
Output is correct |
36 |
Correct |
69 ms |
17328 KB |
Output is correct |
37 |
Runtime error |
733 ms |
524288 KB |
Execution killed with signal 9 |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
709 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
11988 KB |
Output is correct |
2 |
Correct |
15 ms |
17620 KB |
Output is correct |
3 |
Correct |
18 ms |
19504 KB |
Output is correct |
4 |
Correct |
27 ms |
30132 KB |
Output is correct |
5 |
Correct |
3 ms |
6228 KB |
Output is correct |
6 |
Correct |
4 ms |
6228 KB |
Output is correct |
7 |
Correct |
22 ms |
23644 KB |
Output is correct |
8 |
Correct |
21 ms |
23044 KB |
Output is correct |
9 |
Correct |
20 ms |
23124 KB |
Output is correct |
10 |
Correct |
23 ms |
24168 KB |
Output is correct |
11 |
Correct |
23 ms |
24676 KB |
Output is correct |
12 |
Correct |
22 ms |
23716 KB |
Output is correct |
13 |
Correct |
29 ms |
31996 KB |
Output is correct |
14 |
Correct |
35 ms |
37100 KB |
Output is correct |
15 |
Correct |
22 ms |
21808 KB |
Output is correct |
16 |
Correct |
34 ms |
36800 KB |
Output is correct |
17 |
Correct |
12 ms |
15188 KB |
Output is correct |
18 |
Correct |
17 ms |
19928 KB |
Output is correct |
19 |
Correct |
4 ms |
6356 KB |
Output is correct |
20 |
Correct |
4 ms |
6484 KB |
Output is correct |
21 |
Correct |
13 ms |
16584 KB |
Output is correct |
22 |
Correct |
16 ms |
17676 KB |
Output is correct |
23 |
Correct |
18 ms |
21748 KB |
Output is correct |
24 |
Correct |
27 ms |
30188 KB |
Output is correct |
25 |
Correct |
4 ms |
6228 KB |
Output is correct |
26 |
Correct |
3 ms |
6228 KB |
Output is correct |
27 |
Correct |
20 ms |
21040 KB |
Output is correct |
28 |
Correct |
23 ms |
24064 KB |
Output is correct |
29 |
Correct |
24 ms |
23924 KB |
Output is correct |
30 |
Correct |
22 ms |
23500 KB |
Output is correct |
31 |
Correct |
19 ms |
20476 KB |
Output is correct |
32 |
Correct |
19 ms |
20316 KB |
Output is correct |
33 |
Correct |
27 ms |
30356 KB |
Output is correct |
34 |
Correct |
35 ms |
36960 KB |
Output is correct |
35 |
Correct |
27 ms |
28832 KB |
Output is correct |
36 |
Correct |
35 ms |
36536 KB |
Output is correct |
37 |
Correct |
4 ms |
6356 KB |
Output is correct |
38 |
Correct |
5 ms |
6484 KB |
Output is correct |
39 |
Correct |
416 ms |
10476 KB |
Output is correct |
40 |
Correct |
341 ms |
12188 KB |
Output is correct |
41 |
Correct |
431 ms |
13220 KB |
Output is correct |
42 |
Correct |
460 ms |
13400 KB |
Output is correct |
43 |
Correct |
337 ms |
16248 KB |
Output is correct |
44 |
Correct |
371 ms |
16168 KB |
Output is correct |
45 |
Correct |
150 ms |
6888 KB |
Output is correct |
46 |
Correct |
168 ms |
7088 KB |
Output is correct |
47 |
Correct |
706 ms |
10976 KB |
Output is correct |
48 |
Correct |
737 ms |
12188 KB |
Output is correct |
49 |
Correct |
689 ms |
12236 KB |
Output is correct |
50 |
Correct |
742 ms |
12192 KB |
Output is correct |
51 |
Correct |
139 ms |
13360 KB |
Output is correct |
52 |
Correct |
226 ms |
14496 KB |
Output is correct |
53 |
Correct |
59 ms |
16972 KB |
Output is correct |
54 |
Correct |
69 ms |
17328 KB |
Output is correct |
55 |
Runtime error |
733 ms |
524288 KB |
Execution killed with signal 9 |
56 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
11988 KB |
Output is correct |
2 |
Correct |
15 ms |
17620 KB |
Output is correct |
3 |
Correct |
18 ms |
19504 KB |
Output is correct |
4 |
Correct |
27 ms |
30132 KB |
Output is correct |
5 |
Correct |
3 ms |
6228 KB |
Output is correct |
6 |
Correct |
4 ms |
6228 KB |
Output is correct |
7 |
Correct |
22 ms |
23644 KB |
Output is correct |
8 |
Correct |
21 ms |
23044 KB |
Output is correct |
9 |
Correct |
20 ms |
23124 KB |
Output is correct |
10 |
Correct |
23 ms |
24168 KB |
Output is correct |
11 |
Correct |
23 ms |
24676 KB |
Output is correct |
12 |
Correct |
22 ms |
23716 KB |
Output is correct |
13 |
Correct |
29 ms |
31996 KB |
Output is correct |
14 |
Correct |
35 ms |
37100 KB |
Output is correct |
15 |
Correct |
22 ms |
21808 KB |
Output is correct |
16 |
Correct |
34 ms |
36800 KB |
Output is correct |
17 |
Correct |
12 ms |
15188 KB |
Output is correct |
18 |
Correct |
17 ms |
19928 KB |
Output is correct |
19 |
Correct |
4 ms |
6356 KB |
Output is correct |
20 |
Correct |
4 ms |
6484 KB |
Output is correct |
21 |
Correct |
13 ms |
16584 KB |
Output is correct |
22 |
Correct |
16 ms |
17676 KB |
Output is correct |
23 |
Correct |
18 ms |
21748 KB |
Output is correct |
24 |
Correct |
27 ms |
30188 KB |
Output is correct |
25 |
Correct |
4 ms |
6228 KB |
Output is correct |
26 |
Correct |
3 ms |
6228 KB |
Output is correct |
27 |
Correct |
20 ms |
21040 KB |
Output is correct |
28 |
Correct |
23 ms |
24064 KB |
Output is correct |
29 |
Correct |
24 ms |
23924 KB |
Output is correct |
30 |
Correct |
22 ms |
23500 KB |
Output is correct |
31 |
Correct |
19 ms |
20476 KB |
Output is correct |
32 |
Correct |
19 ms |
20316 KB |
Output is correct |
33 |
Correct |
27 ms |
30356 KB |
Output is correct |
34 |
Correct |
35 ms |
36960 KB |
Output is correct |
35 |
Correct |
27 ms |
28832 KB |
Output is correct |
36 |
Correct |
35 ms |
36536 KB |
Output is correct |
37 |
Correct |
4 ms |
6356 KB |
Output is correct |
38 |
Correct |
5 ms |
6484 KB |
Output is correct |
39 |
Correct |
416 ms |
10476 KB |
Output is correct |
40 |
Correct |
341 ms |
12188 KB |
Output is correct |
41 |
Correct |
431 ms |
13220 KB |
Output is correct |
42 |
Correct |
460 ms |
13400 KB |
Output is correct |
43 |
Correct |
337 ms |
16248 KB |
Output is correct |
44 |
Correct |
371 ms |
16168 KB |
Output is correct |
45 |
Correct |
150 ms |
6888 KB |
Output is correct |
46 |
Correct |
168 ms |
7088 KB |
Output is correct |
47 |
Correct |
706 ms |
10976 KB |
Output is correct |
48 |
Correct |
737 ms |
12188 KB |
Output is correct |
49 |
Correct |
689 ms |
12236 KB |
Output is correct |
50 |
Correct |
742 ms |
12192 KB |
Output is correct |
51 |
Correct |
139 ms |
13360 KB |
Output is correct |
52 |
Correct |
226 ms |
14496 KB |
Output is correct |
53 |
Correct |
59 ms |
16972 KB |
Output is correct |
54 |
Correct |
69 ms |
17328 KB |
Output is correct |
55 |
Runtime error |
828 ms |
524288 KB |
Execution killed with signal 9 |
56 |
Halted |
0 ms |
0 KB |
- |