#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;
ll cnt[N];
int n, m, q;
deque < pair < ll , 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({cnt[j], {k, c}});
cnt[j] += k;
}
}
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().sc.fr, b = dq[j].front().sc.sc, cc = dq[j].front().fr;
dq[j].pop_front();
if (a > kc){
dq[j].push_front({cc + kc, {a - kc, b}});
break;
}
kc -= a;
}
}
}
else {
int a;
ll b;
cin >> a >> b;
if (dq[a].empty()){
cout << 0 << endl;
continue;
}
b += dq[a].front().fr;
if (dq[a].back().fr + dq[a].back().sc.fr < b){
cout << 0 << endl;
continue;
}
int l = 0, r = dq[a].size();
while (l + 1 < r){
int mid = (l + r) >> 1;
if (dq[a][mid].fr < b)
l = mid;
else
r = mid;
}
cout << dq[a][l].sc.sc << endl;
}
}
}
Compilation message
foodcourt.cpp:20:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
20 | main (){
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
44504 KB |
Output is correct |
2 |
Correct |
45 ms |
44876 KB |
Output is correct |
3 |
Correct |
65 ms |
51484 KB |
Output is correct |
4 |
Correct |
79 ms |
54992 KB |
Output is correct |
5 |
Correct |
43 ms |
43984 KB |
Output is correct |
6 |
Correct |
42 ms |
44008 KB |
Output is correct |
7 |
Correct |
66 ms |
56600 KB |
Output is correct |
8 |
Correct |
60 ms |
52212 KB |
Output is correct |
9 |
Correct |
53 ms |
44884 KB |
Output is correct |
10 |
Correct |
68 ms |
51624 KB |
Output is correct |
11 |
Correct |
60 ms |
48832 KB |
Output is correct |
12 |
Correct |
54 ms |
44888 KB |
Output is correct |
13 |
Correct |
59 ms |
45004 KB |
Output is correct |
14 |
Correct |
58 ms |
46096 KB |
Output is correct |
15 |
Correct |
85 ms |
47036 KB |
Output is correct |
16 |
Correct |
61 ms |
46020 KB |
Output is correct |
17 |
Correct |
47 ms |
44420 KB |
Output is correct |
18 |
Correct |
55 ms |
44476 KB |
Output is correct |
19 |
Correct |
35 ms |
43988 KB |
Output is correct |
20 |
Correct |
33 ms |
43972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
44504 KB |
Output is correct |
2 |
Correct |
45 ms |
44876 KB |
Output is correct |
3 |
Correct |
65 ms |
51484 KB |
Output is correct |
4 |
Correct |
79 ms |
54992 KB |
Output is correct |
5 |
Correct |
43 ms |
43984 KB |
Output is correct |
6 |
Correct |
42 ms |
44008 KB |
Output is correct |
7 |
Correct |
66 ms |
56600 KB |
Output is correct |
8 |
Correct |
60 ms |
52212 KB |
Output is correct |
9 |
Correct |
53 ms |
44884 KB |
Output is correct |
10 |
Correct |
68 ms |
51624 KB |
Output is correct |
11 |
Correct |
60 ms |
48832 KB |
Output is correct |
12 |
Correct |
54 ms |
44888 KB |
Output is correct |
13 |
Correct |
59 ms |
45004 KB |
Output is correct |
14 |
Correct |
58 ms |
46096 KB |
Output is correct |
15 |
Correct |
85 ms |
47036 KB |
Output is correct |
16 |
Correct |
61 ms |
46020 KB |
Output is correct |
17 |
Correct |
47 ms |
44420 KB |
Output is correct |
18 |
Correct |
55 ms |
44476 KB |
Output is correct |
19 |
Correct |
35 ms |
43988 KB |
Output is correct |
20 |
Correct |
33 ms |
43972 KB |
Output is correct |
21 |
Incorrect |
51 ms |
44776 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1080 ms |
44608 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
79 ms |
89048 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
44504 KB |
Output is correct |
2 |
Correct |
45 ms |
44876 KB |
Output is correct |
3 |
Correct |
65 ms |
51484 KB |
Output is correct |
4 |
Correct |
79 ms |
54992 KB |
Output is correct |
5 |
Correct |
43 ms |
43984 KB |
Output is correct |
6 |
Correct |
42 ms |
44008 KB |
Output is correct |
7 |
Correct |
66 ms |
56600 KB |
Output is correct |
8 |
Correct |
60 ms |
52212 KB |
Output is correct |
9 |
Correct |
53 ms |
44884 KB |
Output is correct |
10 |
Correct |
68 ms |
51624 KB |
Output is correct |
11 |
Correct |
60 ms |
48832 KB |
Output is correct |
12 |
Correct |
54 ms |
44888 KB |
Output is correct |
13 |
Correct |
59 ms |
45004 KB |
Output is correct |
14 |
Correct |
58 ms |
46096 KB |
Output is correct |
15 |
Correct |
85 ms |
47036 KB |
Output is correct |
16 |
Correct |
61 ms |
46020 KB |
Output is correct |
17 |
Correct |
47 ms |
44420 KB |
Output is correct |
18 |
Correct |
55 ms |
44476 KB |
Output is correct |
19 |
Correct |
35 ms |
43988 KB |
Output is correct |
20 |
Correct |
33 ms |
43972 KB |
Output is correct |
21 |
Execution timed out |
1080 ms |
44608 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1130 ms |
302548 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
44504 KB |
Output is correct |
2 |
Correct |
45 ms |
44876 KB |
Output is correct |
3 |
Correct |
65 ms |
51484 KB |
Output is correct |
4 |
Correct |
79 ms |
54992 KB |
Output is correct |
5 |
Correct |
43 ms |
43984 KB |
Output is correct |
6 |
Correct |
42 ms |
44008 KB |
Output is correct |
7 |
Correct |
66 ms |
56600 KB |
Output is correct |
8 |
Correct |
60 ms |
52212 KB |
Output is correct |
9 |
Correct |
53 ms |
44884 KB |
Output is correct |
10 |
Correct |
68 ms |
51624 KB |
Output is correct |
11 |
Correct |
60 ms |
48832 KB |
Output is correct |
12 |
Correct |
54 ms |
44888 KB |
Output is correct |
13 |
Correct |
59 ms |
45004 KB |
Output is correct |
14 |
Correct |
58 ms |
46096 KB |
Output is correct |
15 |
Correct |
85 ms |
47036 KB |
Output is correct |
16 |
Correct |
61 ms |
46020 KB |
Output is correct |
17 |
Correct |
47 ms |
44420 KB |
Output is correct |
18 |
Correct |
55 ms |
44476 KB |
Output is correct |
19 |
Correct |
35 ms |
43988 KB |
Output is correct |
20 |
Correct |
33 ms |
43972 KB |
Output is correct |
21 |
Incorrect |
51 ms |
44776 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
44504 KB |
Output is correct |
2 |
Correct |
45 ms |
44876 KB |
Output is correct |
3 |
Correct |
65 ms |
51484 KB |
Output is correct |
4 |
Correct |
79 ms |
54992 KB |
Output is correct |
5 |
Correct |
43 ms |
43984 KB |
Output is correct |
6 |
Correct |
42 ms |
44008 KB |
Output is correct |
7 |
Correct |
66 ms |
56600 KB |
Output is correct |
8 |
Correct |
60 ms |
52212 KB |
Output is correct |
9 |
Correct |
53 ms |
44884 KB |
Output is correct |
10 |
Correct |
68 ms |
51624 KB |
Output is correct |
11 |
Correct |
60 ms |
48832 KB |
Output is correct |
12 |
Correct |
54 ms |
44888 KB |
Output is correct |
13 |
Correct |
59 ms |
45004 KB |
Output is correct |
14 |
Correct |
58 ms |
46096 KB |
Output is correct |
15 |
Correct |
85 ms |
47036 KB |
Output is correct |
16 |
Correct |
61 ms |
46020 KB |
Output is correct |
17 |
Correct |
47 ms |
44420 KB |
Output is correct |
18 |
Correct |
55 ms |
44476 KB |
Output is correct |
19 |
Correct |
35 ms |
43988 KB |
Output is correct |
20 |
Correct |
33 ms |
43972 KB |
Output is correct |
21 |
Incorrect |
51 ms |
44776 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |