#include <bits/stdc++.h>
using namespace std;
#include <ext/rope>
using namespace __gnu_cxx;
// #pragma comment(linker, "/stack:2000000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define precise(a) cout<<fixed<<setprecision(a)
#define sz size()
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
// t1
const ll mod = ll(1e9)+7; //(b + (a%b)) % b (to mod -1%(10^9+7) correctly in c++ its -1 but its suppose to be 10^9+6
const ll MOD = 998244353; // (a%mod)*(binpow(b,mod-2,mod) = (a/b)%mod
const ll N = ll(3e5)+10;
const ll K = 17;
const ll inf = 1e18;
const ld eps = 1e-15L;
//const ll B = 316;
ll lcm(ll a, ll b){ return (a / __gcd(a,b)) * b; }
//const ld P = acos(-1.0);
// ll binpow(ll a, ll b, ll m){ ll res=1;a%=m; while(b>0){ if(b&1)res=(res*a)%m; a=(a*a)%m; b/=2; } return res%m;}
ld binpow(ld a, ll b){ ld res=1; while(b>0){ if(b&1)res=(res*a); a=(a*a); b/=2; } return res;}
void Freopen(string Key){ freopen((Key+".in").c_str(), "r", stdin); freopen((Key+".out").c_str(), "w", stdout); }
void precalc() {
}
ll n, m, q;
deque<pll>cus[N];
void Baizho()
{
cin>>n>>m>>q;
while(q--) {
ll t; cin>>t;
if(t==1) {
ll l, r, shop, k; cin>>l>>r>>shop>>k;
for(ll i=l; i<=r; i++) {
ll extra = 0;
if(cus[i].sz) {
if(cus[i].back().ss==shop) {
extra = cus[i].back().ff;
cus[i].pop_back();
}
}
cus[i].pb({k+extra, shop});
}
}
else if(t==2) {
ll l, r, k; cin>>l>>r>>k;
for(ll i=l; i<=r; i++) {
ll minus = k;
while(minus && cus[i].sz) {
if(cus[i].front().ff<=minus) {
minus-=cus[i].front().ff;
cus[i].pop_front();
}
else {
ll extra = cus[i].front().ff-minus;
ll shop = cus[i].front().ss;
cus[i].pop_front();
cus[i].push_front({extra, shop});
minus = 0;
}
}
}
}
else {
ll shop, pos; cin>>shop>>pos;
ll totalcus = 0;
vector<pll>vec;
for(auto x : cus[shop]) {
vec.pb(x);
totalcus+=x.ff;
}
if(pos>totalcus) cout<<"0\n";
else {
for(ll i=0; i<vec.sz && pos; i++) {
if(vec[i].ff<pos) pos-=vec[i].ff;
else {
cout<<vec[i].ss<<"\n";
break;
}
}
}
}
}
}
int main() {
// Freopen("div7");
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
precalc();
int ttt = 1;
// cin>>ttt;
for(int i=1; i<=ttt; i++) { Baizho();}
}
Compilation message
foodcourt.cpp: In function 'void Baizho()':
foodcourt.cpp:93:30: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
93 | for(ll i=0; i<vec.sz && pos; i++) {
| ^
foodcourt.cpp: In function 'void Freopen(std::string)':
foodcourt.cpp:37:34: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
37 | void Freopen(string Key){ freopen((Key+".in").c_str(), "r", stdin); freopen((Key+".out").c_str(), "w", stdout); }
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foodcourt.cpp:37:76: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
37 | void Freopen(string Key){ freopen((Key+".in").c_str(), "r", stdin); freopen((Key+".out").c_str(), "w", stdout); }
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
143 ms |
202708 KB |
Output is correct |
2 |
Correct |
151 ms |
203016 KB |
Output is correct |
3 |
Correct |
134 ms |
209612 KB |
Output is correct |
4 |
Correct |
157 ms |
213272 KB |
Output is correct |
5 |
Correct |
128 ms |
202304 KB |
Output is correct |
6 |
Correct |
119 ms |
202256 KB |
Output is correct |
7 |
Correct |
149 ms |
214764 KB |
Output is correct |
8 |
Correct |
143 ms |
210460 KB |
Output is correct |
9 |
Correct |
137 ms |
203044 KB |
Output is correct |
10 |
Correct |
168 ms |
209924 KB |
Output is correct |
11 |
Correct |
159 ms |
206968 KB |
Output is correct |
12 |
Correct |
133 ms |
203244 KB |
Output is correct |
13 |
Correct |
142 ms |
203228 KB |
Output is correct |
14 |
Correct |
150 ms |
204256 KB |
Output is correct |
15 |
Correct |
151 ms |
205264 KB |
Output is correct |
16 |
Correct |
141 ms |
204352 KB |
Output is correct |
17 |
Correct |
131 ms |
202656 KB |
Output is correct |
18 |
Correct |
162 ms |
202808 KB |
Output is correct |
19 |
Correct |
114 ms |
202180 KB |
Output is correct |
20 |
Correct |
119 ms |
202216 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
143 ms |
202708 KB |
Output is correct |
2 |
Correct |
151 ms |
203016 KB |
Output is correct |
3 |
Correct |
134 ms |
209612 KB |
Output is correct |
4 |
Correct |
157 ms |
213272 KB |
Output is correct |
5 |
Correct |
128 ms |
202304 KB |
Output is correct |
6 |
Correct |
119 ms |
202256 KB |
Output is correct |
7 |
Correct |
149 ms |
214764 KB |
Output is correct |
8 |
Correct |
143 ms |
210460 KB |
Output is correct |
9 |
Correct |
137 ms |
203044 KB |
Output is correct |
10 |
Correct |
168 ms |
209924 KB |
Output is correct |
11 |
Correct |
159 ms |
206968 KB |
Output is correct |
12 |
Correct |
133 ms |
203244 KB |
Output is correct |
13 |
Correct |
142 ms |
203228 KB |
Output is correct |
14 |
Correct |
150 ms |
204256 KB |
Output is correct |
15 |
Correct |
151 ms |
205264 KB |
Output is correct |
16 |
Correct |
141 ms |
204352 KB |
Output is correct |
17 |
Correct |
131 ms |
202656 KB |
Output is correct |
18 |
Correct |
162 ms |
202808 KB |
Output is correct |
19 |
Correct |
114 ms |
202180 KB |
Output is correct |
20 |
Correct |
119 ms |
202216 KB |
Output is correct |
21 |
Correct |
137 ms |
203024 KB |
Output is correct |
22 |
Correct |
165 ms |
203180 KB |
Output is correct |
23 |
Correct |
142 ms |
209656 KB |
Output is correct |
24 |
Correct |
142 ms |
213396 KB |
Output is correct |
25 |
Correct |
143 ms |
202244 KB |
Output is correct |
26 |
Correct |
119 ms |
202208 KB |
Output is correct |
27 |
Correct |
164 ms |
214168 KB |
Output is correct |
28 |
Correct |
160 ms |
211224 KB |
Output is correct |
29 |
Correct |
195 ms |
204856 KB |
Output is correct |
30 |
Correct |
163 ms |
209464 KB |
Output is correct |
31 |
Correct |
149 ms |
206908 KB |
Output is correct |
32 |
Correct |
147 ms |
203084 KB |
Output is correct |
33 |
Correct |
219 ms |
203148 KB |
Output is correct |
34 |
Correct |
164 ms |
205404 KB |
Output is correct |
35 |
Correct |
190 ms |
203872 KB |
Output is correct |
36 |
Correct |
211 ms |
204296 KB |
Output is correct |
37 |
Correct |
117 ms |
202288 KB |
Output is correct |
38 |
Correct |
131 ms |
202304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1102 ms |
203404 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1104 ms |
202316 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
143 ms |
202708 KB |
Output is correct |
2 |
Correct |
151 ms |
203016 KB |
Output is correct |
3 |
Correct |
134 ms |
209612 KB |
Output is correct |
4 |
Correct |
157 ms |
213272 KB |
Output is correct |
5 |
Correct |
128 ms |
202304 KB |
Output is correct |
6 |
Correct |
119 ms |
202256 KB |
Output is correct |
7 |
Correct |
149 ms |
214764 KB |
Output is correct |
8 |
Correct |
143 ms |
210460 KB |
Output is correct |
9 |
Correct |
137 ms |
203044 KB |
Output is correct |
10 |
Correct |
168 ms |
209924 KB |
Output is correct |
11 |
Correct |
159 ms |
206968 KB |
Output is correct |
12 |
Correct |
133 ms |
203244 KB |
Output is correct |
13 |
Correct |
142 ms |
203228 KB |
Output is correct |
14 |
Correct |
150 ms |
204256 KB |
Output is correct |
15 |
Correct |
151 ms |
205264 KB |
Output is correct |
16 |
Correct |
141 ms |
204352 KB |
Output is correct |
17 |
Correct |
131 ms |
202656 KB |
Output is correct |
18 |
Correct |
162 ms |
202808 KB |
Output is correct |
19 |
Correct |
114 ms |
202180 KB |
Output is correct |
20 |
Correct |
119 ms |
202216 KB |
Output is correct |
21 |
Execution timed out |
1102 ms |
203404 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
580 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
143 ms |
202708 KB |
Output is correct |
2 |
Correct |
151 ms |
203016 KB |
Output is correct |
3 |
Correct |
134 ms |
209612 KB |
Output is correct |
4 |
Correct |
157 ms |
213272 KB |
Output is correct |
5 |
Correct |
128 ms |
202304 KB |
Output is correct |
6 |
Correct |
119 ms |
202256 KB |
Output is correct |
7 |
Correct |
149 ms |
214764 KB |
Output is correct |
8 |
Correct |
143 ms |
210460 KB |
Output is correct |
9 |
Correct |
137 ms |
203044 KB |
Output is correct |
10 |
Correct |
168 ms |
209924 KB |
Output is correct |
11 |
Correct |
159 ms |
206968 KB |
Output is correct |
12 |
Correct |
133 ms |
203244 KB |
Output is correct |
13 |
Correct |
142 ms |
203228 KB |
Output is correct |
14 |
Correct |
150 ms |
204256 KB |
Output is correct |
15 |
Correct |
151 ms |
205264 KB |
Output is correct |
16 |
Correct |
141 ms |
204352 KB |
Output is correct |
17 |
Correct |
131 ms |
202656 KB |
Output is correct |
18 |
Correct |
162 ms |
202808 KB |
Output is correct |
19 |
Correct |
114 ms |
202180 KB |
Output is correct |
20 |
Correct |
119 ms |
202216 KB |
Output is correct |
21 |
Correct |
137 ms |
203024 KB |
Output is correct |
22 |
Correct |
165 ms |
203180 KB |
Output is correct |
23 |
Correct |
142 ms |
209656 KB |
Output is correct |
24 |
Correct |
142 ms |
213396 KB |
Output is correct |
25 |
Correct |
143 ms |
202244 KB |
Output is correct |
26 |
Correct |
119 ms |
202208 KB |
Output is correct |
27 |
Correct |
164 ms |
214168 KB |
Output is correct |
28 |
Correct |
160 ms |
211224 KB |
Output is correct |
29 |
Correct |
195 ms |
204856 KB |
Output is correct |
30 |
Correct |
163 ms |
209464 KB |
Output is correct |
31 |
Correct |
149 ms |
206908 KB |
Output is correct |
32 |
Correct |
147 ms |
203084 KB |
Output is correct |
33 |
Correct |
219 ms |
203148 KB |
Output is correct |
34 |
Correct |
164 ms |
205404 KB |
Output is correct |
35 |
Correct |
190 ms |
203872 KB |
Output is correct |
36 |
Correct |
211 ms |
204296 KB |
Output is correct |
37 |
Correct |
117 ms |
202288 KB |
Output is correct |
38 |
Correct |
131 ms |
202304 KB |
Output is correct |
39 |
Execution timed out |
1102 ms |
203404 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
143 ms |
202708 KB |
Output is correct |
2 |
Correct |
151 ms |
203016 KB |
Output is correct |
3 |
Correct |
134 ms |
209612 KB |
Output is correct |
4 |
Correct |
157 ms |
213272 KB |
Output is correct |
5 |
Correct |
128 ms |
202304 KB |
Output is correct |
6 |
Correct |
119 ms |
202256 KB |
Output is correct |
7 |
Correct |
149 ms |
214764 KB |
Output is correct |
8 |
Correct |
143 ms |
210460 KB |
Output is correct |
9 |
Correct |
137 ms |
203044 KB |
Output is correct |
10 |
Correct |
168 ms |
209924 KB |
Output is correct |
11 |
Correct |
159 ms |
206968 KB |
Output is correct |
12 |
Correct |
133 ms |
203244 KB |
Output is correct |
13 |
Correct |
142 ms |
203228 KB |
Output is correct |
14 |
Correct |
150 ms |
204256 KB |
Output is correct |
15 |
Correct |
151 ms |
205264 KB |
Output is correct |
16 |
Correct |
141 ms |
204352 KB |
Output is correct |
17 |
Correct |
131 ms |
202656 KB |
Output is correct |
18 |
Correct |
162 ms |
202808 KB |
Output is correct |
19 |
Correct |
114 ms |
202180 KB |
Output is correct |
20 |
Correct |
119 ms |
202216 KB |
Output is correct |
21 |
Correct |
137 ms |
203024 KB |
Output is correct |
22 |
Correct |
165 ms |
203180 KB |
Output is correct |
23 |
Correct |
142 ms |
209656 KB |
Output is correct |
24 |
Correct |
142 ms |
213396 KB |
Output is correct |
25 |
Correct |
143 ms |
202244 KB |
Output is correct |
26 |
Correct |
119 ms |
202208 KB |
Output is correct |
27 |
Correct |
164 ms |
214168 KB |
Output is correct |
28 |
Correct |
160 ms |
211224 KB |
Output is correct |
29 |
Correct |
195 ms |
204856 KB |
Output is correct |
30 |
Correct |
163 ms |
209464 KB |
Output is correct |
31 |
Correct |
149 ms |
206908 KB |
Output is correct |
32 |
Correct |
147 ms |
203084 KB |
Output is correct |
33 |
Correct |
219 ms |
203148 KB |
Output is correct |
34 |
Correct |
164 ms |
205404 KB |
Output is correct |
35 |
Correct |
190 ms |
203872 KB |
Output is correct |
36 |
Correct |
211 ms |
204296 KB |
Output is correct |
37 |
Correct |
117 ms |
202288 KB |
Output is correct |
38 |
Correct |
131 ms |
202304 KB |
Output is correct |
39 |
Execution timed out |
1102 ms |
203404 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |