#include <bits/stdc++.h>
using namespace std;
#define all(s) s.begin(), s.end()
#define int long long
#define ll long long
#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define pi pair < int, int >
const int N = 65007;
const int INF = 1e9 + 7;
ll cnt[N];
int n, m, q;
deque < pair < ll , pi > > dq[N];
main (){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m >> q;
for (int i = 1; i <= q; i++){
int t;
cin >> t;
if (t == 1){
int l, r, c, k;
cin >> l >> r >> c >> k;
for (int j = l; j <= r; j++){
dq[j].pb({cnt[j], {k, c}});
cnt[j] += k;
}
}
else if (t == 2){
int l, r, k;
cin >> l >> r >> k;
for (int j = l; j <= r; j++){
int kc = k;
while (!dq[j].empty() && kc){
int a = dq[j].front().sc.fr, b = dq[j].front().sc.sc, cc = dq[j].front().fr;
dq[j].pop_front();
if (a > kc){
dq[j].push_front({cc + kc, {a - kc, b}});
break;
}
kc -= a;
}
}
}
else {
int a;
ll b;
cin >> a >> b;
if (dq[a].empty()){
cout << 0 << endl;
continue;
}
b += dq[a].front().fr;
if (dq[a].back().fr + 1ll * dq[a].back().sc.fr < b){
cout << 0 << endl;
continue;
}
int l = 0, r = dq[a].size();
while (l + 1 < r){
int mid = (l + r) >> 1;
if (dq[a][mid].fr < b)
l = mid;
else
r = mid;
}
cout << dq[a][l].sc.sc << endl;
}
}
}
Compilation message
foodcourt.cpp:21:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
21 | main (){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
43684 KB |
Output is correct |
2 |
Correct |
45 ms |
44196 KB |
Output is correct |
3 |
Correct |
54 ms |
53836 KB |
Output is correct |
4 |
Correct |
70 ms |
59348 KB |
Output is correct |
5 |
Correct |
34 ms |
42956 KB |
Output is correct |
6 |
Correct |
35 ms |
42948 KB |
Output is correct |
7 |
Correct |
65 ms |
61536 KB |
Output is correct |
8 |
Correct |
61 ms |
55044 KB |
Output is correct |
9 |
Correct |
50 ms |
44264 KB |
Output is correct |
10 |
Correct |
59 ms |
54340 KB |
Output is correct |
11 |
Correct |
61 ms |
50172 KB |
Output is correct |
12 |
Correct |
54 ms |
44276 KB |
Output is correct |
13 |
Correct |
66 ms |
44788 KB |
Output is correct |
14 |
Correct |
61 ms |
46464 KB |
Output is correct |
15 |
Correct |
52 ms |
47012 KB |
Output is correct |
16 |
Correct |
57 ms |
45020 KB |
Output is correct |
17 |
Correct |
43 ms |
43468 KB |
Output is correct |
18 |
Correct |
49 ms |
43728 KB |
Output is correct |
19 |
Correct |
37 ms |
43188 KB |
Output is correct |
20 |
Correct |
34 ms |
43036 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
43684 KB |
Output is correct |
2 |
Correct |
45 ms |
44196 KB |
Output is correct |
3 |
Correct |
54 ms |
53836 KB |
Output is correct |
4 |
Correct |
70 ms |
59348 KB |
Output is correct |
5 |
Correct |
34 ms |
42956 KB |
Output is correct |
6 |
Correct |
35 ms |
42948 KB |
Output is correct |
7 |
Correct |
65 ms |
61536 KB |
Output is correct |
8 |
Correct |
61 ms |
55044 KB |
Output is correct |
9 |
Correct |
50 ms |
44264 KB |
Output is correct |
10 |
Correct |
59 ms |
54340 KB |
Output is correct |
11 |
Correct |
61 ms |
50172 KB |
Output is correct |
12 |
Correct |
54 ms |
44276 KB |
Output is correct |
13 |
Correct |
66 ms |
44788 KB |
Output is correct |
14 |
Correct |
61 ms |
46464 KB |
Output is correct |
15 |
Correct |
52 ms |
47012 KB |
Output is correct |
16 |
Correct |
57 ms |
45020 KB |
Output is correct |
17 |
Correct |
43 ms |
43468 KB |
Output is correct |
18 |
Correct |
49 ms |
43728 KB |
Output is correct |
19 |
Correct |
37 ms |
43188 KB |
Output is correct |
20 |
Correct |
34 ms |
43036 KB |
Output is correct |
21 |
Correct |
48 ms |
44012 KB |
Output is correct |
22 |
Correct |
51 ms |
44332 KB |
Output is correct |
23 |
Correct |
61 ms |
54000 KB |
Output is correct |
24 |
Correct |
81 ms |
59616 KB |
Output is correct |
25 |
Correct |
34 ms |
42984 KB |
Output is correct |
26 |
Correct |
38 ms |
43028 KB |
Output is correct |
27 |
Correct |
86 ms |
60868 KB |
Output is correct |
28 |
Correct |
75 ms |
56132 KB |
Output is correct |
29 |
Correct |
62 ms |
46740 KB |
Output is correct |
30 |
Correct |
71 ms |
53972 KB |
Output is correct |
31 |
Correct |
70 ms |
50028 KB |
Output is correct |
32 |
Correct |
56 ms |
44088 KB |
Output is correct |
33 |
Correct |
61 ms |
44752 KB |
Output is correct |
34 |
Correct |
72 ms |
47192 KB |
Output is correct |
35 |
Correct |
60 ms |
45496 KB |
Output is correct |
36 |
Correct |
69 ms |
45036 KB |
Output is correct |
37 |
Correct |
34 ms |
42972 KB |
Output is correct |
38 |
Correct |
34 ms |
43028 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1082 ms |
43580 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
66 ms |
87108 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
43684 KB |
Output is correct |
2 |
Correct |
45 ms |
44196 KB |
Output is correct |
3 |
Correct |
54 ms |
53836 KB |
Output is correct |
4 |
Correct |
70 ms |
59348 KB |
Output is correct |
5 |
Correct |
34 ms |
42956 KB |
Output is correct |
6 |
Correct |
35 ms |
42948 KB |
Output is correct |
7 |
Correct |
65 ms |
61536 KB |
Output is correct |
8 |
Correct |
61 ms |
55044 KB |
Output is correct |
9 |
Correct |
50 ms |
44264 KB |
Output is correct |
10 |
Correct |
59 ms |
54340 KB |
Output is correct |
11 |
Correct |
61 ms |
50172 KB |
Output is correct |
12 |
Correct |
54 ms |
44276 KB |
Output is correct |
13 |
Correct |
66 ms |
44788 KB |
Output is correct |
14 |
Correct |
61 ms |
46464 KB |
Output is correct |
15 |
Correct |
52 ms |
47012 KB |
Output is correct |
16 |
Correct |
57 ms |
45020 KB |
Output is correct |
17 |
Correct |
43 ms |
43468 KB |
Output is correct |
18 |
Correct |
49 ms |
43728 KB |
Output is correct |
19 |
Correct |
37 ms |
43188 KB |
Output is correct |
20 |
Correct |
34 ms |
43036 KB |
Output is correct |
21 |
Execution timed out |
1082 ms |
43580 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
798 ms |
524292 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
43684 KB |
Output is correct |
2 |
Correct |
45 ms |
44196 KB |
Output is correct |
3 |
Correct |
54 ms |
53836 KB |
Output is correct |
4 |
Correct |
70 ms |
59348 KB |
Output is correct |
5 |
Correct |
34 ms |
42956 KB |
Output is correct |
6 |
Correct |
35 ms |
42948 KB |
Output is correct |
7 |
Correct |
65 ms |
61536 KB |
Output is correct |
8 |
Correct |
61 ms |
55044 KB |
Output is correct |
9 |
Correct |
50 ms |
44264 KB |
Output is correct |
10 |
Correct |
59 ms |
54340 KB |
Output is correct |
11 |
Correct |
61 ms |
50172 KB |
Output is correct |
12 |
Correct |
54 ms |
44276 KB |
Output is correct |
13 |
Correct |
66 ms |
44788 KB |
Output is correct |
14 |
Correct |
61 ms |
46464 KB |
Output is correct |
15 |
Correct |
52 ms |
47012 KB |
Output is correct |
16 |
Correct |
57 ms |
45020 KB |
Output is correct |
17 |
Correct |
43 ms |
43468 KB |
Output is correct |
18 |
Correct |
49 ms |
43728 KB |
Output is correct |
19 |
Correct |
37 ms |
43188 KB |
Output is correct |
20 |
Correct |
34 ms |
43036 KB |
Output is correct |
21 |
Correct |
48 ms |
44012 KB |
Output is correct |
22 |
Correct |
51 ms |
44332 KB |
Output is correct |
23 |
Correct |
61 ms |
54000 KB |
Output is correct |
24 |
Correct |
81 ms |
59616 KB |
Output is correct |
25 |
Correct |
34 ms |
42984 KB |
Output is correct |
26 |
Correct |
38 ms |
43028 KB |
Output is correct |
27 |
Correct |
86 ms |
60868 KB |
Output is correct |
28 |
Correct |
75 ms |
56132 KB |
Output is correct |
29 |
Correct |
62 ms |
46740 KB |
Output is correct |
30 |
Correct |
71 ms |
53972 KB |
Output is correct |
31 |
Correct |
70 ms |
50028 KB |
Output is correct |
32 |
Correct |
56 ms |
44088 KB |
Output is correct |
33 |
Correct |
61 ms |
44752 KB |
Output is correct |
34 |
Correct |
72 ms |
47192 KB |
Output is correct |
35 |
Correct |
60 ms |
45496 KB |
Output is correct |
36 |
Correct |
69 ms |
45036 KB |
Output is correct |
37 |
Correct |
34 ms |
42972 KB |
Output is correct |
38 |
Correct |
34 ms |
43028 KB |
Output is correct |
39 |
Execution timed out |
1082 ms |
43580 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
43684 KB |
Output is correct |
2 |
Correct |
45 ms |
44196 KB |
Output is correct |
3 |
Correct |
54 ms |
53836 KB |
Output is correct |
4 |
Correct |
70 ms |
59348 KB |
Output is correct |
5 |
Correct |
34 ms |
42956 KB |
Output is correct |
6 |
Correct |
35 ms |
42948 KB |
Output is correct |
7 |
Correct |
65 ms |
61536 KB |
Output is correct |
8 |
Correct |
61 ms |
55044 KB |
Output is correct |
9 |
Correct |
50 ms |
44264 KB |
Output is correct |
10 |
Correct |
59 ms |
54340 KB |
Output is correct |
11 |
Correct |
61 ms |
50172 KB |
Output is correct |
12 |
Correct |
54 ms |
44276 KB |
Output is correct |
13 |
Correct |
66 ms |
44788 KB |
Output is correct |
14 |
Correct |
61 ms |
46464 KB |
Output is correct |
15 |
Correct |
52 ms |
47012 KB |
Output is correct |
16 |
Correct |
57 ms |
45020 KB |
Output is correct |
17 |
Correct |
43 ms |
43468 KB |
Output is correct |
18 |
Correct |
49 ms |
43728 KB |
Output is correct |
19 |
Correct |
37 ms |
43188 KB |
Output is correct |
20 |
Correct |
34 ms |
43036 KB |
Output is correct |
21 |
Correct |
48 ms |
44012 KB |
Output is correct |
22 |
Correct |
51 ms |
44332 KB |
Output is correct |
23 |
Correct |
61 ms |
54000 KB |
Output is correct |
24 |
Correct |
81 ms |
59616 KB |
Output is correct |
25 |
Correct |
34 ms |
42984 KB |
Output is correct |
26 |
Correct |
38 ms |
43028 KB |
Output is correct |
27 |
Correct |
86 ms |
60868 KB |
Output is correct |
28 |
Correct |
75 ms |
56132 KB |
Output is correct |
29 |
Correct |
62 ms |
46740 KB |
Output is correct |
30 |
Correct |
71 ms |
53972 KB |
Output is correct |
31 |
Correct |
70 ms |
50028 KB |
Output is correct |
32 |
Correct |
56 ms |
44088 KB |
Output is correct |
33 |
Correct |
61 ms |
44752 KB |
Output is correct |
34 |
Correct |
72 ms |
47192 KB |
Output is correct |
35 |
Correct |
60 ms |
45496 KB |
Output is correct |
36 |
Correct |
69 ms |
45036 KB |
Output is correct |
37 |
Correct |
34 ms |
42972 KB |
Output is correct |
38 |
Correct |
34 ms |
43028 KB |
Output is correct |
39 |
Execution timed out |
1082 ms |
43580 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |