#include <bits/stdc++.h>
using namespace std;
#define all(s) s.begin(), s.end()
#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;
int n, m, q;
deque < 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({k, c});
}
}
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().fr, b = dq[j].front().sc;
dq[j].pop_front();
if (a > kc){
dq[j].push_front({a - kc, b});
break;
}
kc -= a;
}
}
}
else {
int a, b, out = 0;
cin >> a >> b;
for (pi it : dq[a]){
if (b <= it.fr){
out = it.sc;
break;
}
b -= it.fr;
}
cout << out << endl;
}
}
}
Compilation message
foodcourt.cpp:19:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
19 | main (){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
44484 KB |
Output is correct |
2 |
Correct |
44 ms |
44480 KB |
Output is correct |
3 |
Correct |
45 ms |
47712 KB |
Output is correct |
4 |
Correct |
51 ms |
49480 KB |
Output is correct |
5 |
Correct |
32 ms |
43972 KB |
Output is correct |
6 |
Correct |
32 ms |
43992 KB |
Output is correct |
7 |
Correct |
51 ms |
49980 KB |
Output is correct |
8 |
Correct |
48 ms |
48060 KB |
Output is correct |
9 |
Correct |
47 ms |
44512 KB |
Output is correct |
10 |
Correct |
46 ms |
47812 KB |
Output is correct |
11 |
Correct |
47 ms |
46540 KB |
Output is correct |
12 |
Correct |
46 ms |
44472 KB |
Output is correct |
13 |
Correct |
46 ms |
45028 KB |
Output is correct |
14 |
Correct |
55 ms |
45132 KB |
Output is correct |
15 |
Correct |
50 ms |
45984 KB |
Output is correct |
16 |
Correct |
50 ms |
45124 KB |
Output is correct |
17 |
Correct |
42 ms |
44296 KB |
Output is correct |
18 |
Correct |
46 ms |
44504 KB |
Output is correct |
19 |
Correct |
33 ms |
44008 KB |
Output is correct |
20 |
Correct |
38 ms |
44064 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
44484 KB |
Output is correct |
2 |
Correct |
44 ms |
44480 KB |
Output is correct |
3 |
Correct |
45 ms |
47712 KB |
Output is correct |
4 |
Correct |
51 ms |
49480 KB |
Output is correct |
5 |
Correct |
32 ms |
43972 KB |
Output is correct |
6 |
Correct |
32 ms |
43992 KB |
Output is correct |
7 |
Correct |
51 ms |
49980 KB |
Output is correct |
8 |
Correct |
48 ms |
48060 KB |
Output is correct |
9 |
Correct |
47 ms |
44512 KB |
Output is correct |
10 |
Correct |
46 ms |
47812 KB |
Output is correct |
11 |
Correct |
47 ms |
46540 KB |
Output is correct |
12 |
Correct |
46 ms |
44472 KB |
Output is correct |
13 |
Correct |
46 ms |
45028 KB |
Output is correct |
14 |
Correct |
55 ms |
45132 KB |
Output is correct |
15 |
Correct |
50 ms |
45984 KB |
Output is correct |
16 |
Correct |
50 ms |
45124 KB |
Output is correct |
17 |
Correct |
42 ms |
44296 KB |
Output is correct |
18 |
Correct |
46 ms |
44504 KB |
Output is correct |
19 |
Correct |
33 ms |
44008 KB |
Output is correct |
20 |
Correct |
38 ms |
44064 KB |
Output is correct |
21 |
Incorrect |
37 ms |
44136 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1089 ms |
45372 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
66 ms |
89216 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
44484 KB |
Output is correct |
2 |
Correct |
44 ms |
44480 KB |
Output is correct |
3 |
Correct |
45 ms |
47712 KB |
Output is correct |
4 |
Correct |
51 ms |
49480 KB |
Output is correct |
5 |
Correct |
32 ms |
43972 KB |
Output is correct |
6 |
Correct |
32 ms |
43992 KB |
Output is correct |
7 |
Correct |
51 ms |
49980 KB |
Output is correct |
8 |
Correct |
48 ms |
48060 KB |
Output is correct |
9 |
Correct |
47 ms |
44512 KB |
Output is correct |
10 |
Correct |
46 ms |
47812 KB |
Output is correct |
11 |
Correct |
47 ms |
46540 KB |
Output is correct |
12 |
Correct |
46 ms |
44472 KB |
Output is correct |
13 |
Correct |
46 ms |
45028 KB |
Output is correct |
14 |
Correct |
55 ms |
45132 KB |
Output is correct |
15 |
Correct |
50 ms |
45984 KB |
Output is correct |
16 |
Correct |
50 ms |
45124 KB |
Output is correct |
17 |
Correct |
42 ms |
44296 KB |
Output is correct |
18 |
Correct |
46 ms |
44504 KB |
Output is correct |
19 |
Correct |
33 ms |
44008 KB |
Output is correct |
20 |
Correct |
38 ms |
44064 KB |
Output is correct |
21 |
Execution timed out |
1089 ms |
45372 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
136 ms |
44556 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
44484 KB |
Output is correct |
2 |
Correct |
44 ms |
44480 KB |
Output is correct |
3 |
Correct |
45 ms |
47712 KB |
Output is correct |
4 |
Correct |
51 ms |
49480 KB |
Output is correct |
5 |
Correct |
32 ms |
43972 KB |
Output is correct |
6 |
Correct |
32 ms |
43992 KB |
Output is correct |
7 |
Correct |
51 ms |
49980 KB |
Output is correct |
8 |
Correct |
48 ms |
48060 KB |
Output is correct |
9 |
Correct |
47 ms |
44512 KB |
Output is correct |
10 |
Correct |
46 ms |
47812 KB |
Output is correct |
11 |
Correct |
47 ms |
46540 KB |
Output is correct |
12 |
Correct |
46 ms |
44472 KB |
Output is correct |
13 |
Correct |
46 ms |
45028 KB |
Output is correct |
14 |
Correct |
55 ms |
45132 KB |
Output is correct |
15 |
Correct |
50 ms |
45984 KB |
Output is correct |
16 |
Correct |
50 ms |
45124 KB |
Output is correct |
17 |
Correct |
42 ms |
44296 KB |
Output is correct |
18 |
Correct |
46 ms |
44504 KB |
Output is correct |
19 |
Correct |
33 ms |
44008 KB |
Output is correct |
20 |
Correct |
38 ms |
44064 KB |
Output is correct |
21 |
Incorrect |
37 ms |
44136 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
44484 KB |
Output is correct |
2 |
Correct |
44 ms |
44480 KB |
Output is correct |
3 |
Correct |
45 ms |
47712 KB |
Output is correct |
4 |
Correct |
51 ms |
49480 KB |
Output is correct |
5 |
Correct |
32 ms |
43972 KB |
Output is correct |
6 |
Correct |
32 ms |
43992 KB |
Output is correct |
7 |
Correct |
51 ms |
49980 KB |
Output is correct |
8 |
Correct |
48 ms |
48060 KB |
Output is correct |
9 |
Correct |
47 ms |
44512 KB |
Output is correct |
10 |
Correct |
46 ms |
47812 KB |
Output is correct |
11 |
Correct |
47 ms |
46540 KB |
Output is correct |
12 |
Correct |
46 ms |
44472 KB |
Output is correct |
13 |
Correct |
46 ms |
45028 KB |
Output is correct |
14 |
Correct |
55 ms |
45132 KB |
Output is correct |
15 |
Correct |
50 ms |
45984 KB |
Output is correct |
16 |
Correct |
50 ms |
45124 KB |
Output is correct |
17 |
Correct |
42 ms |
44296 KB |
Output is correct |
18 |
Correct |
46 ms |
44504 KB |
Output is correct |
19 |
Correct |
33 ms |
44008 KB |
Output is correct |
20 |
Correct |
38 ms |
44064 KB |
Output is correct |
21 |
Incorrect |
37 ms |
44136 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |