#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#pragma GCC optimize ("O3")
typedef int64_t ll;
typedef long double ld;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int,int>
#define F(n) Fi(i,n)
#define Fi(i,n) Fl(i,0,n)
#define Fl(i,l,n) for(int i=l;i<n;i++)
#define RF(n) RFi(i,n)
#define RFi(i,n) RFl(i,0,n)
#define RFl(i,l,n) for(int i=n-1;i>=l;i--)
#define all(v) begin(v),end(v)
#define siz(v) (ll(v.size()))
#define get_pos(v,x) (lower_bound(all(v),x)-begin(v))
#define sort_uni(v) sort(begin(v),end(v)),v.erase(unique(begin(v),end(v)),end(v))
#define mem(v,x) memset(v,x,sizeof v)
#define ff first
#define ss second
#define mid ((l+r)>>1)
#define RAN(a,b) uniform_int_distribution<int> (a, b)(rng)
#define debug(x) (cerr << (#x) << " = " << x << "\n")
template <typename T> using max_heap = __gnu_pbds::priority_queue<T,less<T> >;
template <typename T> using min_heap = __gnu_pbds::priority_queue<T,greater<T> >;
template <typename T> using rbt = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const int maxN = 250010;
vector<int> qs[maxN];
int N,M,Q;
namespace sub3{
const int maxN = 65010;
void solve(){
vector<int> shop[maxN];
int ptr[maxN];
Fi(j, Q){
vector<int> curr = qs[j];
if(curr[0] == 1){
Fl(i, curr[1], curr[2]+1){
shop[i].push_back(curr[3]);
}
}
if(curr[0] == 2){
Fl(i, curr[1], curr[2]+1){
int K = curr[3];
if(shop[i].size() - ptr[i] <= K){
ptr[i] = shop[i].size();
}else{
ptr[i] += K;
}
}
}
if(curr[0] == 3){
int b = curr[2];
if(shop[curr[1]].size() - ptr[curr[1]] >= b){
cout << shop[curr[1]][ptr[curr[1]] + b - 1];
}else{
cout << 0;
}
cout << "\n";
}
}
}
}
namespace sub2{
const int maxN = 65010;
void solve(){
deque<pii> shop[maxN];
Fi(j, Q){
vector<int> curr = qs[j];
if(curr[0] == 1){
Fl(i, curr[1], curr[2]+1){
shop[i].push_back(mp(curr[3], curr[4]));
}
}
if(curr[0] == 2){
Fl(i, curr[1], curr[2]+1){
int K = curr[3];
while(!shop[i].empty() && K){
if(shop[i][0].ss > K){
shop[i][0].ss -= K;
K = 0;
}else{
K -= shop[i][0].ss;
shop[i].pop_front();
}
}
}
}
if(curr[0] == 3){
int b = curr[2];
deque<pii> now = shop[curr[1]];
for(pii p : now){
if(b <= p.ss){
cout << p.ff << "\n";
b = 0;
break;
}else{
b -= p.ss;
}
}
if(b) cout << "0\n";
}
}
}
}
signed main(){
cin.tie(0);
ios_base::sync_with_stdio(false);
cin >> N >> M >> Q;
int x;
F(Q){
int t;
cin >> t;
qs[i].pb(t);
Fi(j, 5-t){
cin >> x;
qs[i].pb(x);
}
}
if(N <= 2000 && Q <= 2000){
sub2::solve();
return 0;
}
bool __sub3 = true;
F(Q){
if(qs[i][0] == 1 && (qs[i][2] - qs[i][1] > 10 || qs[i][4] != 1)){
__sub3 = false;
}
}
if( N <= 65000 && Q <= 65000 && __sub3){
sub3::solve();
return 0;
}
assert(0);
return 0;
}
Compilation message
foodcourt.cpp: In function 'void sub3::solve()':
foodcourt.cpp:54:38: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'long long int' [-Wsign-compare]
54 | if(shop[i].size() - ptr[i] <= K){
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~
foodcourt.cpp:63:48: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'long long int' [-Wsign-compare]
63 | if(shop[curr[1]].size() - ptr[curr[1]] >= b){
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
50388 KB |
Output is correct |
2 |
Correct |
41 ms |
50868 KB |
Output is correct |
3 |
Correct |
47 ms |
57388 KB |
Output is correct |
4 |
Correct |
52 ms |
60932 KB |
Output is correct |
5 |
Correct |
32 ms |
50040 KB |
Output is correct |
6 |
Correct |
36 ms |
49984 KB |
Output is correct |
7 |
Correct |
56 ms |
62528 KB |
Output is correct |
8 |
Correct |
52 ms |
58116 KB |
Output is correct |
9 |
Correct |
56 ms |
50872 KB |
Output is correct |
10 |
Correct |
59 ms |
57676 KB |
Output is correct |
11 |
Correct |
60 ms |
54732 KB |
Output is correct |
12 |
Correct |
45 ms |
50924 KB |
Output is correct |
13 |
Correct |
44 ms |
50976 KB |
Output is correct |
14 |
Correct |
49 ms |
52120 KB |
Output is correct |
15 |
Correct |
49 ms |
52948 KB |
Output is correct |
16 |
Correct |
52 ms |
52076 KB |
Output is correct |
17 |
Correct |
43 ms |
50392 KB |
Output is correct |
18 |
Correct |
41 ms |
50528 KB |
Output is correct |
19 |
Correct |
33 ms |
49996 KB |
Output is correct |
20 |
Correct |
34 ms |
50044 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
50388 KB |
Output is correct |
2 |
Correct |
41 ms |
50868 KB |
Output is correct |
3 |
Correct |
47 ms |
57388 KB |
Output is correct |
4 |
Correct |
52 ms |
60932 KB |
Output is correct |
5 |
Correct |
32 ms |
50040 KB |
Output is correct |
6 |
Correct |
36 ms |
49984 KB |
Output is correct |
7 |
Correct |
56 ms |
62528 KB |
Output is correct |
8 |
Correct |
52 ms |
58116 KB |
Output is correct |
9 |
Correct |
56 ms |
50872 KB |
Output is correct |
10 |
Correct |
59 ms |
57676 KB |
Output is correct |
11 |
Correct |
60 ms |
54732 KB |
Output is correct |
12 |
Correct |
45 ms |
50924 KB |
Output is correct |
13 |
Correct |
44 ms |
50976 KB |
Output is correct |
14 |
Correct |
49 ms |
52120 KB |
Output is correct |
15 |
Correct |
49 ms |
52948 KB |
Output is correct |
16 |
Correct |
52 ms |
52076 KB |
Output is correct |
17 |
Correct |
43 ms |
50392 KB |
Output is correct |
18 |
Correct |
41 ms |
50528 KB |
Output is correct |
19 |
Correct |
33 ms |
49996 KB |
Output is correct |
20 |
Correct |
34 ms |
50044 KB |
Output is correct |
21 |
Correct |
45 ms |
50764 KB |
Output is correct |
22 |
Correct |
46 ms |
50860 KB |
Output is correct |
23 |
Correct |
60 ms |
57416 KB |
Output is correct |
24 |
Correct |
57 ms |
61068 KB |
Output is correct |
25 |
Correct |
34 ms |
50036 KB |
Output is correct |
26 |
Correct |
37 ms |
50052 KB |
Output is correct |
27 |
Correct |
54 ms |
61972 KB |
Output is correct |
28 |
Correct |
60 ms |
58912 KB |
Output is correct |
29 |
Correct |
64 ms |
52584 KB |
Output is correct |
30 |
Correct |
52 ms |
57260 KB |
Output is correct |
31 |
Correct |
47 ms |
54616 KB |
Output is correct |
32 |
Correct |
44 ms |
50764 KB |
Output is correct |
33 |
Correct |
48 ms |
50900 KB |
Output is correct |
34 |
Correct |
56 ms |
53160 KB |
Output is correct |
35 |
Correct |
52 ms |
51532 KB |
Output is correct |
36 |
Correct |
65 ms |
52092 KB |
Output is correct |
37 |
Correct |
35 ms |
50032 KB |
Output is correct |
38 |
Correct |
34 ms |
50068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
566 ms |
14204 KB |
Output is correct |
2 |
Correct |
418 ms |
15592 KB |
Output is correct |
3 |
Correct |
585 ms |
15692 KB |
Output is correct |
4 |
Correct |
589 ms |
15596 KB |
Output is correct |
5 |
Correct |
442 ms |
17536 KB |
Output is correct |
6 |
Correct |
415 ms |
17504 KB |
Output is correct |
7 |
Correct |
34 ms |
12108 KB |
Output is correct |
8 |
Correct |
39 ms |
12340 KB |
Output is correct |
9 |
Correct |
880 ms |
14556 KB |
Output is correct |
10 |
Correct |
923 ms |
15812 KB |
Output is correct |
11 |
Correct |
905 ms |
15792 KB |
Output is correct |
12 |
Correct |
852 ms |
15704 KB |
Output is correct |
13 |
Correct |
187 ms |
16152 KB |
Output is correct |
14 |
Correct |
255 ms |
17188 KB |
Output is correct |
15 |
Correct |
79 ms |
18980 KB |
Output is correct |
16 |
Correct |
114 ms |
19244 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
137 ms |
38996 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
50388 KB |
Output is correct |
2 |
Correct |
41 ms |
50868 KB |
Output is correct |
3 |
Correct |
47 ms |
57388 KB |
Output is correct |
4 |
Correct |
52 ms |
60932 KB |
Output is correct |
5 |
Correct |
32 ms |
50040 KB |
Output is correct |
6 |
Correct |
36 ms |
49984 KB |
Output is correct |
7 |
Correct |
56 ms |
62528 KB |
Output is correct |
8 |
Correct |
52 ms |
58116 KB |
Output is correct |
9 |
Correct |
56 ms |
50872 KB |
Output is correct |
10 |
Correct |
59 ms |
57676 KB |
Output is correct |
11 |
Correct |
60 ms |
54732 KB |
Output is correct |
12 |
Correct |
45 ms |
50924 KB |
Output is correct |
13 |
Correct |
44 ms |
50976 KB |
Output is correct |
14 |
Correct |
49 ms |
52120 KB |
Output is correct |
15 |
Correct |
49 ms |
52948 KB |
Output is correct |
16 |
Correct |
52 ms |
52076 KB |
Output is correct |
17 |
Correct |
43 ms |
50392 KB |
Output is correct |
18 |
Correct |
41 ms |
50528 KB |
Output is correct |
19 |
Correct |
33 ms |
49996 KB |
Output is correct |
20 |
Correct |
34 ms |
50044 KB |
Output is correct |
21 |
Correct |
566 ms |
14204 KB |
Output is correct |
22 |
Correct |
418 ms |
15592 KB |
Output is correct |
23 |
Correct |
585 ms |
15692 KB |
Output is correct |
24 |
Correct |
589 ms |
15596 KB |
Output is correct |
25 |
Correct |
442 ms |
17536 KB |
Output is correct |
26 |
Correct |
415 ms |
17504 KB |
Output is correct |
27 |
Correct |
34 ms |
12108 KB |
Output is correct |
28 |
Correct |
39 ms |
12340 KB |
Output is correct |
29 |
Correct |
880 ms |
14556 KB |
Output is correct |
30 |
Correct |
923 ms |
15812 KB |
Output is correct |
31 |
Correct |
905 ms |
15792 KB |
Output is correct |
32 |
Correct |
852 ms |
15704 KB |
Output is correct |
33 |
Correct |
187 ms |
16152 KB |
Output is correct |
34 |
Correct |
255 ms |
17188 KB |
Output is correct |
35 |
Correct |
79 ms |
18980 KB |
Output is correct |
36 |
Correct |
114 ms |
19244 KB |
Output is correct |
37 |
Runtime error |
42 ms |
20040 KB |
Execution killed with signal 6 |
38 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
42 ms |
19704 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
50388 KB |
Output is correct |
2 |
Correct |
41 ms |
50868 KB |
Output is correct |
3 |
Correct |
47 ms |
57388 KB |
Output is correct |
4 |
Correct |
52 ms |
60932 KB |
Output is correct |
5 |
Correct |
32 ms |
50040 KB |
Output is correct |
6 |
Correct |
36 ms |
49984 KB |
Output is correct |
7 |
Correct |
56 ms |
62528 KB |
Output is correct |
8 |
Correct |
52 ms |
58116 KB |
Output is correct |
9 |
Correct |
56 ms |
50872 KB |
Output is correct |
10 |
Correct |
59 ms |
57676 KB |
Output is correct |
11 |
Correct |
60 ms |
54732 KB |
Output is correct |
12 |
Correct |
45 ms |
50924 KB |
Output is correct |
13 |
Correct |
44 ms |
50976 KB |
Output is correct |
14 |
Correct |
49 ms |
52120 KB |
Output is correct |
15 |
Correct |
49 ms |
52948 KB |
Output is correct |
16 |
Correct |
52 ms |
52076 KB |
Output is correct |
17 |
Correct |
43 ms |
50392 KB |
Output is correct |
18 |
Correct |
41 ms |
50528 KB |
Output is correct |
19 |
Correct |
33 ms |
49996 KB |
Output is correct |
20 |
Correct |
34 ms |
50044 KB |
Output is correct |
21 |
Correct |
45 ms |
50764 KB |
Output is correct |
22 |
Correct |
46 ms |
50860 KB |
Output is correct |
23 |
Correct |
60 ms |
57416 KB |
Output is correct |
24 |
Correct |
57 ms |
61068 KB |
Output is correct |
25 |
Correct |
34 ms |
50036 KB |
Output is correct |
26 |
Correct |
37 ms |
50052 KB |
Output is correct |
27 |
Correct |
54 ms |
61972 KB |
Output is correct |
28 |
Correct |
60 ms |
58912 KB |
Output is correct |
29 |
Correct |
64 ms |
52584 KB |
Output is correct |
30 |
Correct |
52 ms |
57260 KB |
Output is correct |
31 |
Correct |
47 ms |
54616 KB |
Output is correct |
32 |
Correct |
44 ms |
50764 KB |
Output is correct |
33 |
Correct |
48 ms |
50900 KB |
Output is correct |
34 |
Correct |
56 ms |
53160 KB |
Output is correct |
35 |
Correct |
52 ms |
51532 KB |
Output is correct |
36 |
Correct |
65 ms |
52092 KB |
Output is correct |
37 |
Correct |
35 ms |
50032 KB |
Output is correct |
38 |
Correct |
34 ms |
50068 KB |
Output is correct |
39 |
Correct |
566 ms |
14204 KB |
Output is correct |
40 |
Correct |
418 ms |
15592 KB |
Output is correct |
41 |
Correct |
585 ms |
15692 KB |
Output is correct |
42 |
Correct |
589 ms |
15596 KB |
Output is correct |
43 |
Correct |
442 ms |
17536 KB |
Output is correct |
44 |
Correct |
415 ms |
17504 KB |
Output is correct |
45 |
Correct |
34 ms |
12108 KB |
Output is correct |
46 |
Correct |
39 ms |
12340 KB |
Output is correct |
47 |
Correct |
880 ms |
14556 KB |
Output is correct |
48 |
Correct |
923 ms |
15812 KB |
Output is correct |
49 |
Correct |
905 ms |
15792 KB |
Output is correct |
50 |
Correct |
852 ms |
15704 KB |
Output is correct |
51 |
Correct |
187 ms |
16152 KB |
Output is correct |
52 |
Correct |
255 ms |
17188 KB |
Output is correct |
53 |
Correct |
79 ms |
18980 KB |
Output is correct |
54 |
Correct |
114 ms |
19244 KB |
Output is correct |
55 |
Runtime error |
42 ms |
20040 KB |
Execution killed with signal 6 |
56 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
50388 KB |
Output is correct |
2 |
Correct |
41 ms |
50868 KB |
Output is correct |
3 |
Correct |
47 ms |
57388 KB |
Output is correct |
4 |
Correct |
52 ms |
60932 KB |
Output is correct |
5 |
Correct |
32 ms |
50040 KB |
Output is correct |
6 |
Correct |
36 ms |
49984 KB |
Output is correct |
7 |
Correct |
56 ms |
62528 KB |
Output is correct |
8 |
Correct |
52 ms |
58116 KB |
Output is correct |
9 |
Correct |
56 ms |
50872 KB |
Output is correct |
10 |
Correct |
59 ms |
57676 KB |
Output is correct |
11 |
Correct |
60 ms |
54732 KB |
Output is correct |
12 |
Correct |
45 ms |
50924 KB |
Output is correct |
13 |
Correct |
44 ms |
50976 KB |
Output is correct |
14 |
Correct |
49 ms |
52120 KB |
Output is correct |
15 |
Correct |
49 ms |
52948 KB |
Output is correct |
16 |
Correct |
52 ms |
52076 KB |
Output is correct |
17 |
Correct |
43 ms |
50392 KB |
Output is correct |
18 |
Correct |
41 ms |
50528 KB |
Output is correct |
19 |
Correct |
33 ms |
49996 KB |
Output is correct |
20 |
Correct |
34 ms |
50044 KB |
Output is correct |
21 |
Correct |
45 ms |
50764 KB |
Output is correct |
22 |
Correct |
46 ms |
50860 KB |
Output is correct |
23 |
Correct |
60 ms |
57416 KB |
Output is correct |
24 |
Correct |
57 ms |
61068 KB |
Output is correct |
25 |
Correct |
34 ms |
50036 KB |
Output is correct |
26 |
Correct |
37 ms |
50052 KB |
Output is correct |
27 |
Correct |
54 ms |
61972 KB |
Output is correct |
28 |
Correct |
60 ms |
58912 KB |
Output is correct |
29 |
Correct |
64 ms |
52584 KB |
Output is correct |
30 |
Correct |
52 ms |
57260 KB |
Output is correct |
31 |
Correct |
47 ms |
54616 KB |
Output is correct |
32 |
Correct |
44 ms |
50764 KB |
Output is correct |
33 |
Correct |
48 ms |
50900 KB |
Output is correct |
34 |
Correct |
56 ms |
53160 KB |
Output is correct |
35 |
Correct |
52 ms |
51532 KB |
Output is correct |
36 |
Correct |
65 ms |
52092 KB |
Output is correct |
37 |
Correct |
35 ms |
50032 KB |
Output is correct |
38 |
Correct |
34 ms |
50068 KB |
Output is correct |
39 |
Correct |
566 ms |
14204 KB |
Output is correct |
40 |
Correct |
418 ms |
15592 KB |
Output is correct |
41 |
Correct |
585 ms |
15692 KB |
Output is correct |
42 |
Correct |
589 ms |
15596 KB |
Output is correct |
43 |
Correct |
442 ms |
17536 KB |
Output is correct |
44 |
Correct |
415 ms |
17504 KB |
Output is correct |
45 |
Correct |
34 ms |
12108 KB |
Output is correct |
46 |
Correct |
39 ms |
12340 KB |
Output is correct |
47 |
Correct |
880 ms |
14556 KB |
Output is correct |
48 |
Correct |
923 ms |
15812 KB |
Output is correct |
49 |
Correct |
905 ms |
15792 KB |
Output is correct |
50 |
Correct |
852 ms |
15704 KB |
Output is correct |
51 |
Correct |
187 ms |
16152 KB |
Output is correct |
52 |
Correct |
255 ms |
17188 KB |
Output is correct |
53 |
Correct |
79 ms |
18980 KB |
Output is correct |
54 |
Correct |
114 ms |
19244 KB |
Output is correct |
55 |
Runtime error |
137 ms |
38996 KB |
Execution killed with signal 6 |
56 |
Halted |
0 ms |
0 KB |
- |