#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define int long long
deque <pair<int,int>> queues[2001];
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n,m,q;
cin >> n >> m >> q;
for(int i=1;i<=q;i++){
int type;cin>>type;
if(type==1){
int l,r,c,k;cin>>l>>r>>c>>k;
for(int x=l;x<=r;x++)queues[x].emplace_back(k,c);
} else if(type==2){
int l,r,k;cin>>l>>r>>k;
for(int x=l;x<=r;x++){
int tar = k;
while(tar and !queues[x].empty()){
if(queues[x].front().first<=tar){
tar-=queues[x].front().first;
queues[x].pop_front();
} else {
queues[x].front().first-=tar;
tar = 0;
}
}
}
} else {
int a,b;cin>>a>>b;
int curr = 0;
for(int i=0;i<queues[a].size();i++){
curr+=queues[a][i].first;
if(curr>=b){cout<<queues[a][i].second<<'\n';break;}
}
if(curr<b)cout<<"0\n";
}
}
}
Compilation message
foodcourt.cpp: In function 'int32_t main()':
foodcourt.cpp:38:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::deque<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | for(int i=0;i<queues[a].size();i++){
| ~^~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2140 KB |
Output is correct |
2 |
Correct |
4 ms |
2396 KB |
Output is correct |
3 |
Correct |
7 ms |
9068 KB |
Output is correct |
4 |
Correct |
10 ms |
12636 KB |
Output is correct |
5 |
Correct |
1 ms |
1628 KB |
Output is correct |
6 |
Correct |
1 ms |
1628 KB |
Output is correct |
7 |
Correct |
11 ms |
14172 KB |
Output is correct |
8 |
Correct |
9 ms |
9748 KB |
Output is correct |
9 |
Correct |
6 ms |
2652 KB |
Output is correct |
10 |
Correct |
10 ms |
9308 KB |
Output is correct |
11 |
Correct |
8 ms |
6492 KB |
Output is correct |
12 |
Correct |
7 ms |
2652 KB |
Output is correct |
13 |
Correct |
9 ms |
2756 KB |
Output is correct |
14 |
Correct |
11 ms |
3852 KB |
Output is correct |
15 |
Correct |
8 ms |
4640 KB |
Output is correct |
16 |
Correct |
9 ms |
3872 KB |
Output is correct |
17 |
Correct |
4 ms |
2140 KB |
Output is correct |
18 |
Correct |
5 ms |
2140 KB |
Output is correct |
19 |
Correct |
1 ms |
1628 KB |
Output is correct |
20 |
Correct |
1 ms |
1628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2140 KB |
Output is correct |
2 |
Correct |
4 ms |
2396 KB |
Output is correct |
3 |
Correct |
7 ms |
9068 KB |
Output is correct |
4 |
Correct |
10 ms |
12636 KB |
Output is correct |
5 |
Correct |
1 ms |
1628 KB |
Output is correct |
6 |
Correct |
1 ms |
1628 KB |
Output is correct |
7 |
Correct |
11 ms |
14172 KB |
Output is correct |
8 |
Correct |
9 ms |
9748 KB |
Output is correct |
9 |
Correct |
6 ms |
2652 KB |
Output is correct |
10 |
Correct |
10 ms |
9308 KB |
Output is correct |
11 |
Correct |
8 ms |
6492 KB |
Output is correct |
12 |
Correct |
7 ms |
2652 KB |
Output is correct |
13 |
Correct |
9 ms |
2756 KB |
Output is correct |
14 |
Correct |
11 ms |
3852 KB |
Output is correct |
15 |
Correct |
8 ms |
4640 KB |
Output is correct |
16 |
Correct |
9 ms |
3872 KB |
Output is correct |
17 |
Correct |
4 ms |
2140 KB |
Output is correct |
18 |
Correct |
5 ms |
2140 KB |
Output is correct |
19 |
Correct |
1 ms |
1628 KB |
Output is correct |
20 |
Correct |
1 ms |
1628 KB |
Output is correct |
21 |
Correct |
5 ms |
2396 KB |
Output is correct |
22 |
Correct |
6 ms |
2652 KB |
Output is correct |
23 |
Correct |
8 ms |
9052 KB |
Output is correct |
24 |
Correct |
10 ms |
12892 KB |
Output is correct |
25 |
Correct |
1 ms |
1628 KB |
Output is correct |
26 |
Correct |
1 ms |
1832 KB |
Output is correct |
27 |
Correct |
11 ms |
13660 KB |
Output is correct |
28 |
Correct |
11 ms |
10588 KB |
Output is correct |
29 |
Correct |
7 ms |
4420 KB |
Output is correct |
30 |
Correct |
10 ms |
8980 KB |
Output is correct |
31 |
Correct |
9 ms |
6476 KB |
Output is correct |
32 |
Correct |
6 ms |
2436 KB |
Output is correct |
33 |
Correct |
9 ms |
2676 KB |
Output is correct |
34 |
Correct |
12 ms |
4924 KB |
Output is correct |
35 |
Correct |
8 ms |
3404 KB |
Output is correct |
36 |
Correct |
10 ms |
3676 KB |
Output is correct |
37 |
Correct |
1 ms |
1828 KB |
Output is correct |
38 |
Correct |
1 ms |
1628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
3164 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
3164 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2140 KB |
Output is correct |
2 |
Correct |
4 ms |
2396 KB |
Output is correct |
3 |
Correct |
7 ms |
9068 KB |
Output is correct |
4 |
Correct |
10 ms |
12636 KB |
Output is correct |
5 |
Correct |
1 ms |
1628 KB |
Output is correct |
6 |
Correct |
1 ms |
1628 KB |
Output is correct |
7 |
Correct |
11 ms |
14172 KB |
Output is correct |
8 |
Correct |
9 ms |
9748 KB |
Output is correct |
9 |
Correct |
6 ms |
2652 KB |
Output is correct |
10 |
Correct |
10 ms |
9308 KB |
Output is correct |
11 |
Correct |
8 ms |
6492 KB |
Output is correct |
12 |
Correct |
7 ms |
2652 KB |
Output is correct |
13 |
Correct |
9 ms |
2756 KB |
Output is correct |
14 |
Correct |
11 ms |
3852 KB |
Output is correct |
15 |
Correct |
8 ms |
4640 KB |
Output is correct |
16 |
Correct |
9 ms |
3872 KB |
Output is correct |
17 |
Correct |
4 ms |
2140 KB |
Output is correct |
18 |
Correct |
5 ms |
2140 KB |
Output is correct |
19 |
Correct |
1 ms |
1628 KB |
Output is correct |
20 |
Correct |
1 ms |
1628 KB |
Output is correct |
21 |
Runtime error |
2 ms |
3164 KB |
Execution killed with signal 11 |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
3164 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2140 KB |
Output is correct |
2 |
Correct |
4 ms |
2396 KB |
Output is correct |
3 |
Correct |
7 ms |
9068 KB |
Output is correct |
4 |
Correct |
10 ms |
12636 KB |
Output is correct |
5 |
Correct |
1 ms |
1628 KB |
Output is correct |
6 |
Correct |
1 ms |
1628 KB |
Output is correct |
7 |
Correct |
11 ms |
14172 KB |
Output is correct |
8 |
Correct |
9 ms |
9748 KB |
Output is correct |
9 |
Correct |
6 ms |
2652 KB |
Output is correct |
10 |
Correct |
10 ms |
9308 KB |
Output is correct |
11 |
Correct |
8 ms |
6492 KB |
Output is correct |
12 |
Correct |
7 ms |
2652 KB |
Output is correct |
13 |
Correct |
9 ms |
2756 KB |
Output is correct |
14 |
Correct |
11 ms |
3852 KB |
Output is correct |
15 |
Correct |
8 ms |
4640 KB |
Output is correct |
16 |
Correct |
9 ms |
3872 KB |
Output is correct |
17 |
Correct |
4 ms |
2140 KB |
Output is correct |
18 |
Correct |
5 ms |
2140 KB |
Output is correct |
19 |
Correct |
1 ms |
1628 KB |
Output is correct |
20 |
Correct |
1 ms |
1628 KB |
Output is correct |
21 |
Correct |
5 ms |
2396 KB |
Output is correct |
22 |
Correct |
6 ms |
2652 KB |
Output is correct |
23 |
Correct |
8 ms |
9052 KB |
Output is correct |
24 |
Correct |
10 ms |
12892 KB |
Output is correct |
25 |
Correct |
1 ms |
1628 KB |
Output is correct |
26 |
Correct |
1 ms |
1832 KB |
Output is correct |
27 |
Correct |
11 ms |
13660 KB |
Output is correct |
28 |
Correct |
11 ms |
10588 KB |
Output is correct |
29 |
Correct |
7 ms |
4420 KB |
Output is correct |
30 |
Correct |
10 ms |
8980 KB |
Output is correct |
31 |
Correct |
9 ms |
6476 KB |
Output is correct |
32 |
Correct |
6 ms |
2436 KB |
Output is correct |
33 |
Correct |
9 ms |
2676 KB |
Output is correct |
34 |
Correct |
12 ms |
4924 KB |
Output is correct |
35 |
Correct |
8 ms |
3404 KB |
Output is correct |
36 |
Correct |
10 ms |
3676 KB |
Output is correct |
37 |
Correct |
1 ms |
1828 KB |
Output is correct |
38 |
Correct |
1 ms |
1628 KB |
Output is correct |
39 |
Runtime error |
2 ms |
3164 KB |
Execution killed with signal 11 |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2140 KB |
Output is correct |
2 |
Correct |
4 ms |
2396 KB |
Output is correct |
3 |
Correct |
7 ms |
9068 KB |
Output is correct |
4 |
Correct |
10 ms |
12636 KB |
Output is correct |
5 |
Correct |
1 ms |
1628 KB |
Output is correct |
6 |
Correct |
1 ms |
1628 KB |
Output is correct |
7 |
Correct |
11 ms |
14172 KB |
Output is correct |
8 |
Correct |
9 ms |
9748 KB |
Output is correct |
9 |
Correct |
6 ms |
2652 KB |
Output is correct |
10 |
Correct |
10 ms |
9308 KB |
Output is correct |
11 |
Correct |
8 ms |
6492 KB |
Output is correct |
12 |
Correct |
7 ms |
2652 KB |
Output is correct |
13 |
Correct |
9 ms |
2756 KB |
Output is correct |
14 |
Correct |
11 ms |
3852 KB |
Output is correct |
15 |
Correct |
8 ms |
4640 KB |
Output is correct |
16 |
Correct |
9 ms |
3872 KB |
Output is correct |
17 |
Correct |
4 ms |
2140 KB |
Output is correct |
18 |
Correct |
5 ms |
2140 KB |
Output is correct |
19 |
Correct |
1 ms |
1628 KB |
Output is correct |
20 |
Correct |
1 ms |
1628 KB |
Output is correct |
21 |
Correct |
5 ms |
2396 KB |
Output is correct |
22 |
Correct |
6 ms |
2652 KB |
Output is correct |
23 |
Correct |
8 ms |
9052 KB |
Output is correct |
24 |
Correct |
10 ms |
12892 KB |
Output is correct |
25 |
Correct |
1 ms |
1628 KB |
Output is correct |
26 |
Correct |
1 ms |
1832 KB |
Output is correct |
27 |
Correct |
11 ms |
13660 KB |
Output is correct |
28 |
Correct |
11 ms |
10588 KB |
Output is correct |
29 |
Correct |
7 ms |
4420 KB |
Output is correct |
30 |
Correct |
10 ms |
8980 KB |
Output is correct |
31 |
Correct |
9 ms |
6476 KB |
Output is correct |
32 |
Correct |
6 ms |
2436 KB |
Output is correct |
33 |
Correct |
9 ms |
2676 KB |
Output is correct |
34 |
Correct |
12 ms |
4924 KB |
Output is correct |
35 |
Correct |
8 ms |
3404 KB |
Output is correct |
36 |
Correct |
10 ms |
3676 KB |
Output is correct |
37 |
Correct |
1 ms |
1828 KB |
Output is correct |
38 |
Correct |
1 ms |
1628 KB |
Output is correct |
39 |
Runtime error |
2 ms |
3164 KB |
Execution killed with signal 11 |
40 |
Halted |
0 ms |
0 KB |
- |