#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
#define int long long
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 sub2{
const int maxN = 2e3+10;
deque<pii> shop[maxN];
void solve(){
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 >> 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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
8020 KB |
Output is correct |
2 |
Correct |
11 ms |
8404 KB |
Output is correct |
3 |
Correct |
16 ms |
15008 KB |
Output is correct |
4 |
Correct |
26 ms |
18644 KB |
Output is correct |
5 |
Correct |
7 ms |
7544 KB |
Output is correct |
6 |
Correct |
6 ms |
7636 KB |
Output is correct |
7 |
Correct |
30 ms |
20160 KB |
Output is correct |
8 |
Correct |
24 ms |
15828 KB |
Output is correct |
9 |
Correct |
15 ms |
8380 KB |
Output is correct |
10 |
Correct |
22 ms |
15208 KB |
Output is correct |
11 |
Correct |
20 ms |
12532 KB |
Output is correct |
12 |
Correct |
14 ms |
8508 KB |
Output is correct |
13 |
Correct |
14 ms |
8532 KB |
Output is correct |
14 |
Correct |
20 ms |
9728 KB |
Output is correct |
15 |
Correct |
14 ms |
10580 KB |
Output is correct |
16 |
Correct |
22 ms |
9684 KB |
Output is correct |
17 |
Correct |
10 ms |
8020 KB |
Output is correct |
18 |
Correct |
12 ms |
8188 KB |
Output is correct |
19 |
Correct |
6 ms |
7676 KB |
Output is correct |
20 |
Correct |
7 ms |
7636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
8020 KB |
Output is correct |
2 |
Correct |
11 ms |
8404 KB |
Output is correct |
3 |
Correct |
16 ms |
15008 KB |
Output is correct |
4 |
Correct |
26 ms |
18644 KB |
Output is correct |
5 |
Correct |
7 ms |
7544 KB |
Output is correct |
6 |
Correct |
6 ms |
7636 KB |
Output is correct |
7 |
Correct |
30 ms |
20160 KB |
Output is correct |
8 |
Correct |
24 ms |
15828 KB |
Output is correct |
9 |
Correct |
15 ms |
8380 KB |
Output is correct |
10 |
Correct |
22 ms |
15208 KB |
Output is correct |
11 |
Correct |
20 ms |
12532 KB |
Output is correct |
12 |
Correct |
14 ms |
8508 KB |
Output is correct |
13 |
Correct |
14 ms |
8532 KB |
Output is correct |
14 |
Correct |
20 ms |
9728 KB |
Output is correct |
15 |
Correct |
14 ms |
10580 KB |
Output is correct |
16 |
Correct |
22 ms |
9684 KB |
Output is correct |
17 |
Correct |
10 ms |
8020 KB |
Output is correct |
18 |
Correct |
12 ms |
8188 KB |
Output is correct |
19 |
Correct |
6 ms |
7676 KB |
Output is correct |
20 |
Correct |
7 ms |
7636 KB |
Output is correct |
21 |
Correct |
13 ms |
8372 KB |
Output is correct |
22 |
Correct |
15 ms |
8484 KB |
Output is correct |
23 |
Correct |
20 ms |
15060 KB |
Output is correct |
24 |
Correct |
27 ms |
18780 KB |
Output is correct |
25 |
Correct |
6 ms |
7636 KB |
Output is correct |
26 |
Correct |
6 ms |
7636 KB |
Output is correct |
27 |
Correct |
27 ms |
19656 KB |
Output is correct |
28 |
Correct |
25 ms |
16596 KB |
Output is correct |
29 |
Correct |
19 ms |
10256 KB |
Output is correct |
30 |
Correct |
24 ms |
14796 KB |
Output is correct |
31 |
Correct |
27 ms |
12284 KB |
Output is correct |
32 |
Correct |
20 ms |
8444 KB |
Output is correct |
33 |
Correct |
21 ms |
8532 KB |
Output is correct |
34 |
Correct |
24 ms |
10792 KB |
Output is correct |
35 |
Correct |
17 ms |
9244 KB |
Output is correct |
36 |
Correct |
23 ms |
9720 KB |
Output is correct |
37 |
Correct |
6 ms |
7548 KB |
Output is correct |
38 |
Correct |
6 ms |
7636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
75 ms |
12416 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
312 ms |
25040 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
8020 KB |
Output is correct |
2 |
Correct |
11 ms |
8404 KB |
Output is correct |
3 |
Correct |
16 ms |
15008 KB |
Output is correct |
4 |
Correct |
26 ms |
18644 KB |
Output is correct |
5 |
Correct |
7 ms |
7544 KB |
Output is correct |
6 |
Correct |
6 ms |
7636 KB |
Output is correct |
7 |
Correct |
30 ms |
20160 KB |
Output is correct |
8 |
Correct |
24 ms |
15828 KB |
Output is correct |
9 |
Correct |
15 ms |
8380 KB |
Output is correct |
10 |
Correct |
22 ms |
15208 KB |
Output is correct |
11 |
Correct |
20 ms |
12532 KB |
Output is correct |
12 |
Correct |
14 ms |
8508 KB |
Output is correct |
13 |
Correct |
14 ms |
8532 KB |
Output is correct |
14 |
Correct |
20 ms |
9728 KB |
Output is correct |
15 |
Correct |
14 ms |
10580 KB |
Output is correct |
16 |
Correct |
22 ms |
9684 KB |
Output is correct |
17 |
Correct |
10 ms |
8020 KB |
Output is correct |
18 |
Correct |
12 ms |
8188 KB |
Output is correct |
19 |
Correct |
6 ms |
7676 KB |
Output is correct |
20 |
Correct |
7 ms |
7636 KB |
Output is correct |
21 |
Incorrect |
75 ms |
12416 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
80 ms |
12572 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
8020 KB |
Output is correct |
2 |
Correct |
11 ms |
8404 KB |
Output is correct |
3 |
Correct |
16 ms |
15008 KB |
Output is correct |
4 |
Correct |
26 ms |
18644 KB |
Output is correct |
5 |
Correct |
7 ms |
7544 KB |
Output is correct |
6 |
Correct |
6 ms |
7636 KB |
Output is correct |
7 |
Correct |
30 ms |
20160 KB |
Output is correct |
8 |
Correct |
24 ms |
15828 KB |
Output is correct |
9 |
Correct |
15 ms |
8380 KB |
Output is correct |
10 |
Correct |
22 ms |
15208 KB |
Output is correct |
11 |
Correct |
20 ms |
12532 KB |
Output is correct |
12 |
Correct |
14 ms |
8508 KB |
Output is correct |
13 |
Correct |
14 ms |
8532 KB |
Output is correct |
14 |
Correct |
20 ms |
9728 KB |
Output is correct |
15 |
Correct |
14 ms |
10580 KB |
Output is correct |
16 |
Correct |
22 ms |
9684 KB |
Output is correct |
17 |
Correct |
10 ms |
8020 KB |
Output is correct |
18 |
Correct |
12 ms |
8188 KB |
Output is correct |
19 |
Correct |
6 ms |
7676 KB |
Output is correct |
20 |
Correct |
7 ms |
7636 KB |
Output is correct |
21 |
Correct |
13 ms |
8372 KB |
Output is correct |
22 |
Correct |
15 ms |
8484 KB |
Output is correct |
23 |
Correct |
20 ms |
15060 KB |
Output is correct |
24 |
Correct |
27 ms |
18780 KB |
Output is correct |
25 |
Correct |
6 ms |
7636 KB |
Output is correct |
26 |
Correct |
6 ms |
7636 KB |
Output is correct |
27 |
Correct |
27 ms |
19656 KB |
Output is correct |
28 |
Correct |
25 ms |
16596 KB |
Output is correct |
29 |
Correct |
19 ms |
10256 KB |
Output is correct |
30 |
Correct |
24 ms |
14796 KB |
Output is correct |
31 |
Correct |
27 ms |
12284 KB |
Output is correct |
32 |
Correct |
20 ms |
8444 KB |
Output is correct |
33 |
Correct |
21 ms |
8532 KB |
Output is correct |
34 |
Correct |
24 ms |
10792 KB |
Output is correct |
35 |
Correct |
17 ms |
9244 KB |
Output is correct |
36 |
Correct |
23 ms |
9720 KB |
Output is correct |
37 |
Correct |
6 ms |
7548 KB |
Output is correct |
38 |
Correct |
6 ms |
7636 KB |
Output is correct |
39 |
Incorrect |
75 ms |
12416 KB |
Output isn't correct |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
8020 KB |
Output is correct |
2 |
Correct |
11 ms |
8404 KB |
Output is correct |
3 |
Correct |
16 ms |
15008 KB |
Output is correct |
4 |
Correct |
26 ms |
18644 KB |
Output is correct |
5 |
Correct |
7 ms |
7544 KB |
Output is correct |
6 |
Correct |
6 ms |
7636 KB |
Output is correct |
7 |
Correct |
30 ms |
20160 KB |
Output is correct |
8 |
Correct |
24 ms |
15828 KB |
Output is correct |
9 |
Correct |
15 ms |
8380 KB |
Output is correct |
10 |
Correct |
22 ms |
15208 KB |
Output is correct |
11 |
Correct |
20 ms |
12532 KB |
Output is correct |
12 |
Correct |
14 ms |
8508 KB |
Output is correct |
13 |
Correct |
14 ms |
8532 KB |
Output is correct |
14 |
Correct |
20 ms |
9728 KB |
Output is correct |
15 |
Correct |
14 ms |
10580 KB |
Output is correct |
16 |
Correct |
22 ms |
9684 KB |
Output is correct |
17 |
Correct |
10 ms |
8020 KB |
Output is correct |
18 |
Correct |
12 ms |
8188 KB |
Output is correct |
19 |
Correct |
6 ms |
7676 KB |
Output is correct |
20 |
Correct |
7 ms |
7636 KB |
Output is correct |
21 |
Correct |
13 ms |
8372 KB |
Output is correct |
22 |
Correct |
15 ms |
8484 KB |
Output is correct |
23 |
Correct |
20 ms |
15060 KB |
Output is correct |
24 |
Correct |
27 ms |
18780 KB |
Output is correct |
25 |
Correct |
6 ms |
7636 KB |
Output is correct |
26 |
Correct |
6 ms |
7636 KB |
Output is correct |
27 |
Correct |
27 ms |
19656 KB |
Output is correct |
28 |
Correct |
25 ms |
16596 KB |
Output is correct |
29 |
Correct |
19 ms |
10256 KB |
Output is correct |
30 |
Correct |
24 ms |
14796 KB |
Output is correct |
31 |
Correct |
27 ms |
12284 KB |
Output is correct |
32 |
Correct |
20 ms |
8444 KB |
Output is correct |
33 |
Correct |
21 ms |
8532 KB |
Output is correct |
34 |
Correct |
24 ms |
10792 KB |
Output is correct |
35 |
Correct |
17 ms |
9244 KB |
Output is correct |
36 |
Correct |
23 ms |
9720 KB |
Output is correct |
37 |
Correct |
6 ms |
7548 KB |
Output is correct |
38 |
Correct |
6 ms |
7636 KB |
Output is correct |
39 |
Incorrect |
75 ms |
12416 KB |
Output isn't correct |
40 |
Halted |
0 ms |
0 KB |
- |