#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 2.5e5 + 10;
const int MOD = 1e9 + 7;
mt19937_64 rng((int)std::chrono::steady_clock::now().time_since_epoch().count());
int rnd(int x, int y) {
int u = uniform_int_distribution<int>(x, y)(rng);
return u;
}
int N, M, Q;
vector<pair<int, int> > v[MAXN];
int ptr[MAXN];
void join(int l, int r, int c, int k) {
for(int i=l; i<=r; i++) {
v[i].push_back({c, k});
}
}
void leave(int l, int r, int k) {
for(int i=l; i<=r; i++) {
ptr[i] += k;
ptr[i] = min(ptr[i], (int)v[i].size());
}
}
int service(int a, int b) {
if(ptr[a] + b - 1 <= v[a].size() - 1) return v[a][ptr[a] + b - 1].first;
else return 0;
}
void solve(int tc) {
int N, M, Q;
cin >> N >> M >> Q;
while(Q--) {
int t;
cin >> t;
if(t == 1) {
int l, r, c, k;
cin >> l >> r >> c >> k;
join(l, r, c, k);
}
else if(t == 2) {
int l, r, k;
cin >> l >> r >> k;
leave(l, r, k);
}
else {
int a, b;
cin >> a >> b;
cout << service(a, b) << "\n";
}
}
}
int32_t main(){
ios::sync_with_stdio(0); cin.tie(0);
int t = 1; //cin >> t;
for(int i=1; i<=t; i++) {
solve(i);
}
}
Compilation message
foodcourt.cpp: In function 'long long int service(long long int, long long int)':
foodcourt.cpp:32:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | if(ptr[a] + b - 1 <= v[a].size() - 1) return v[a][ptr[a] + b - 1].first;
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
9 ms |
12380 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
9 ms |
12380 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
8 ms |
12364 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
8 ms |
12344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
9 ms |
12380 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
8 ms |
12340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
9 ms |
12380 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
9 ms |
12380 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |