답안 #994963

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
994963 2024-06-08T08:55:38 Z snpmrnhlol 푸드 코트 (JOI21_foodcourt) C++17
68 / 100
1000 ms 45660 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 25e4;
struct nod{
    ll lazysum2;
    ll lazysum,lazymn;
}seg[4*N];
bool ok[N];
ll rem[N],val[N];
ll n,m,q;
ll qcnt = 0,updcnt = 0;
vector <pair<ll,ll>> queries[N];
vector <ll> updates[N + 1];
pair<ll,ll> updates2[N];
ll ans[N];
void push(ll node, ll l, ll r){
    if(l != r){
        seg[node*2].lazysum2+=seg[node].lazysum2;
        seg[node*2 + 1].lazysum2+=seg[node].lazysum2;
        seg[node*2].lazymn = min(seg[node*2].lazymn,seg[node*2].lazysum + seg[node].lazymn);
        seg[node*2 + 1].lazymn = min(seg[node*2 + 1].lazymn,seg[node*2 + 1].lazysum + seg[node].lazymn);
        seg[node*2].lazysum+=seg[node].lazysum;
        seg[node*2 + 1].lazysum+=seg[node].lazysum;
    }else{
        val[l]+=seg[node].lazysum2;
        if(rem[l] + seg[node].lazymn <= 0){
            rem[l] = seg[node].lazysum - seg[node].lazymn;
        }else{
            rem[l]+=seg[node].lazysum;
        }
    }
    seg[node].lazysum2 = 0;
    seg[node].lazysum = 0;
    seg[node].lazymn = 0;
}
void upd(ll ql, ll qr, ll x, ll l = 0, ll r = n - 1, ll node = 1){
    push(node,l,r);
    if(ql <= l && r <= qr){
        seg[node].lazysum+=x;
        if(x >= 0)seg[node].lazysum2+=x;
        seg[node].lazymn = min(seg[node].lazymn,seg[node].lazysum);
    }else{
        ll mij = (l + r)/2;
        if(qr <= mij){
            upd(ql,qr,x,l,mij,node*2);
        }else if(mij + 1 <= ql){
            upd(ql,qr,x,mij + 1,r,node*2 + 1);
        }else{
            upd(ql,qr,x,l,mij,node*2);
            upd(ql,qr,x,mij + 1,r,node*2 + 1);
        }
    }
}
void get(ll pos,ll l = 0,ll r = n - 1,ll node = 1){
    push(node,l,r);
    if(l != r){
        ll mij = (l + r)/2;
        if(pos <= mij){
            return get(pos,l,mij,node*2);
        }else{
            return get(pos,mij + 1,r,node*2 + 1);
        }
    }
}
void upd2(ll pos){
    ok[pos]^=1;
}
ll get2(ll x){
    for(ll i = 0;i < updcnt;i++){
        if(ok[i]){
            //cout<<"query\n"<<x<<'\n';;
            //cout<<updates2[i].first<<' '<<updates2[i].second<<'\n';
            x-=updates2[i].second;
            if(x <= 0)return updates2[i].first;
        }
    }
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>m>>q;
    for(ll i = 0;i < q;i++){
        ll tip;
        cin>>tip;
        if(tip == 1){
            ll l,r,c,k;
            cin>>l>>r>>c>>k;
            l--;r--;
            upd(l,r,k);
            updates2[updcnt] = {c,k};
            updates[l].push_back(updcnt);
            updates[r + 1].push_back(updcnt);
            updcnt++;
        }else if(tip == 2){
            ll l,r,k;
            cin>>l>>r>>k;
            l--;r--;
            upd(l,r,-k);
        }else{
            ll a,b;
            cin>>a>>b;
            a--;
            get(a);
            //cout<<"update:"<<val[a]<<' '<<rem[a]<<'\n';
            if(rem[a] < b){
                ans[qcnt++] = 0;
                //cout<<ans[qcnt - 1]<<'\n';
            }else{
                queries[a].push_back({qcnt++,b + val[a] - rem[a]});
                //cout<<b + val[a] - rem[a]<<"th customer from"<<a<<'\n';
            }
        }
    }
    for(ll i = 0;i < n;i++){
        for(auto j:updates[i]){
            upd2(j);
        }
        for(auto j:queries[i]){
            ans[j.first] = get2(j.second);
        }
    }
    for(ll i = 0;i < qcnt;i++){
        cout<<ans[i]<<'\n';
    }
    return 0;
}
/**
3 5 5
1 2 3 5 2
1 1 2 2 4
2 1 3 3
1 2 3 4 2
3 3 2
**/

Compilation message

foodcourt.cpp: In function 'll get2(ll)':
foodcourt.cpp:78:1: warning: control reaches end of non-void function [-Wreturn-type]
   78 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 16988 KB Output is correct
2 Correct 3 ms 16988 KB Output is correct
3 Correct 4 ms 16988 KB Output is correct
4 Correct 4 ms 16988 KB Output is correct
5 Correct 3 ms 16812 KB Output is correct
6 Correct 4 ms 16732 KB Output is correct
7 Correct 3 ms 16988 KB Output is correct
8 Correct 4 ms 16988 KB Output is correct
9 Correct 4 ms 16988 KB Output is correct
10 Correct 4 ms 16984 KB Output is correct
11 Correct 4 ms 16984 KB Output is correct
12 Correct 4 ms 16988 KB Output is correct
13 Correct 3 ms 16828 KB Output is correct
14 Correct 3 ms 16988 KB Output is correct
15 Correct 3 ms 16988 KB Output is correct
16 Correct 4 ms 16988 KB Output is correct
17 Correct 4 ms 16988 KB Output is correct
18 Correct 4 ms 16988 KB Output is correct
19 Correct 4 ms 16988 KB Output is correct
20 Correct 4 ms 17044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 16988 KB Output is correct
2 Correct 3 ms 16988 KB Output is correct
3 Correct 4 ms 16988 KB Output is correct
4 Correct 4 ms 16988 KB Output is correct
5 Correct 3 ms 16812 KB Output is correct
6 Correct 4 ms 16732 KB Output is correct
7 Correct 3 ms 16988 KB Output is correct
8 Correct 4 ms 16988 KB Output is correct
9 Correct 4 ms 16988 KB Output is correct
10 Correct 4 ms 16984 KB Output is correct
11 Correct 4 ms 16984 KB Output is correct
12 Correct 4 ms 16988 KB Output is correct
13 Correct 3 ms 16828 KB Output is correct
14 Correct 3 ms 16988 KB Output is correct
15 Correct 3 ms 16988 KB Output is correct
16 Correct 4 ms 16988 KB Output is correct
17 Correct 4 ms 16988 KB Output is correct
18 Correct 4 ms 16988 KB Output is correct
19 Correct 4 ms 16988 KB Output is correct
20 Correct 4 ms 17044 KB Output is correct
21 Correct 5 ms 16988 KB Output is correct
22 Correct 4 ms 16988 KB Output is correct
23 Correct 4 ms 16984 KB Output is correct
24 Correct 4 ms 16988 KB Output is correct
25 Correct 4 ms 16728 KB Output is correct
26 Correct 3 ms 16988 KB Output is correct
27 Correct 4 ms 16988 KB Output is correct
28 Correct 6 ms 16988 KB Output is correct
29 Correct 4 ms 16988 KB Output is correct
30 Correct 6 ms 17096 KB Output is correct
31 Correct 6 ms 17036 KB Output is correct
32 Correct 6 ms 16988 KB Output is correct
33 Correct 3 ms 16988 KB Output is correct
34 Correct 3 ms 17068 KB Output is correct
35 Correct 5 ms 16984 KB Output is correct
36 Correct 4 ms 16988 KB Output is correct
37 Correct 4 ms 16988 KB Output is correct
38 Correct 4 ms 17084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 26964 KB Output is correct
2 Correct 50 ms 27216 KB Output is correct
3 Correct 38 ms 26876 KB Output is correct
4 Correct 37 ms 26964 KB Output is correct
5 Correct 44 ms 27288 KB Output is correct
6 Correct 37 ms 27216 KB Output is correct
7 Correct 50 ms 20560 KB Output is correct
8 Correct 69 ms 20444 KB Output is correct
9 Correct 43 ms 26932 KB Output is correct
10 Correct 43 ms 26964 KB Output is correct
11 Correct 42 ms 26964 KB Output is correct
12 Correct 41 ms 26972 KB Output is correct
13 Correct 61 ms 26716 KB Output is correct
14 Correct 79 ms 27216 KB Output is correct
15 Correct 38 ms 27484 KB Output is correct
16 Correct 38 ms 27724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1074 ms 45660 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 16988 KB Output is correct
2 Correct 3 ms 16988 KB Output is correct
3 Correct 4 ms 16988 KB Output is correct
4 Correct 4 ms 16988 KB Output is correct
5 Correct 3 ms 16812 KB Output is correct
6 Correct 4 ms 16732 KB Output is correct
7 Correct 3 ms 16988 KB Output is correct
8 Correct 4 ms 16988 KB Output is correct
9 Correct 4 ms 16988 KB Output is correct
10 Correct 4 ms 16984 KB Output is correct
11 Correct 4 ms 16984 KB Output is correct
12 Correct 4 ms 16988 KB Output is correct
13 Correct 3 ms 16828 KB Output is correct
14 Correct 3 ms 16988 KB Output is correct
15 Correct 3 ms 16988 KB Output is correct
16 Correct 4 ms 16988 KB Output is correct
17 Correct 4 ms 16988 KB Output is correct
18 Correct 4 ms 16988 KB Output is correct
19 Correct 4 ms 16988 KB Output is correct
20 Correct 4 ms 17044 KB Output is correct
21 Correct 60 ms 26964 KB Output is correct
22 Correct 50 ms 27216 KB Output is correct
23 Correct 38 ms 26876 KB Output is correct
24 Correct 37 ms 26964 KB Output is correct
25 Correct 44 ms 27288 KB Output is correct
26 Correct 37 ms 27216 KB Output is correct
27 Correct 50 ms 20560 KB Output is correct
28 Correct 69 ms 20444 KB Output is correct
29 Correct 43 ms 26932 KB Output is correct
30 Correct 43 ms 26964 KB Output is correct
31 Correct 42 ms 26964 KB Output is correct
32 Correct 41 ms 26972 KB Output is correct
33 Correct 61 ms 26716 KB Output is correct
34 Correct 79 ms 27216 KB Output is correct
35 Correct 38 ms 27484 KB Output is correct
36 Correct 38 ms 27724 KB Output is correct
37 Correct 141 ms 26956 KB Output is correct
38 Correct 118 ms 26708 KB Output is correct
39 Correct 59 ms 20224 KB Output is correct
40 Correct 90 ms 20572 KB Output is correct
41 Correct 185 ms 27216 KB Output is correct
42 Correct 170 ms 27236 KB Output is correct
43 Correct 153 ms 27180 KB Output is correct
44 Correct 182 ms 27220 KB Output is correct
45 Correct 165 ms 27220 KB Output is correct
46 Correct 167 ms 27200 KB Output is correct
47 Correct 105 ms 26444 KB Output is correct
48 Correct 125 ms 26708 KB Output is correct
49 Correct 103 ms 26196 KB Output is correct
50 Correct 106 ms 26612 KB Output is correct
51 Correct 158 ms 26976 KB Output is correct
52 Correct 151 ms 27216 KB Output is correct
53 Correct 44 ms 26972 KB Output is correct
54 Correct 41 ms 27740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 181 ms 27908 KB Output is correct
2 Correct 244 ms 28240 KB Output is correct
3 Correct 236 ms 28448 KB Output is correct
4 Correct 125 ms 27228 KB Output is correct
5 Correct 181 ms 27988 KB Output is correct
6 Correct 250 ms 28440 KB Output is correct
7 Correct 104 ms 21360 KB Output is correct
8 Correct 141 ms 21340 KB Output is correct
9 Correct 139 ms 27452 KB Output is correct
10 Correct 86 ms 26712 KB Output is correct
11 Correct 168 ms 27728 KB Output is correct
12 Correct 169 ms 27736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 16988 KB Output is correct
2 Correct 3 ms 16988 KB Output is correct
3 Correct 4 ms 16988 KB Output is correct
4 Correct 4 ms 16988 KB Output is correct
5 Correct 3 ms 16812 KB Output is correct
6 Correct 4 ms 16732 KB Output is correct
7 Correct 3 ms 16988 KB Output is correct
8 Correct 4 ms 16988 KB Output is correct
9 Correct 4 ms 16988 KB Output is correct
10 Correct 4 ms 16984 KB Output is correct
11 Correct 4 ms 16984 KB Output is correct
12 Correct 4 ms 16988 KB Output is correct
13 Correct 3 ms 16828 KB Output is correct
14 Correct 3 ms 16988 KB Output is correct
15 Correct 3 ms 16988 KB Output is correct
16 Correct 4 ms 16988 KB Output is correct
17 Correct 4 ms 16988 KB Output is correct
18 Correct 4 ms 16988 KB Output is correct
19 Correct 4 ms 16988 KB Output is correct
20 Correct 4 ms 17044 KB Output is correct
21 Correct 5 ms 16988 KB Output is correct
22 Correct 4 ms 16988 KB Output is correct
23 Correct 4 ms 16984 KB Output is correct
24 Correct 4 ms 16988 KB Output is correct
25 Correct 4 ms 16728 KB Output is correct
26 Correct 3 ms 16988 KB Output is correct
27 Correct 4 ms 16988 KB Output is correct
28 Correct 6 ms 16988 KB Output is correct
29 Correct 4 ms 16988 KB Output is correct
30 Correct 6 ms 17096 KB Output is correct
31 Correct 6 ms 17036 KB Output is correct
32 Correct 6 ms 16988 KB Output is correct
33 Correct 3 ms 16988 KB Output is correct
34 Correct 3 ms 17068 KB Output is correct
35 Correct 5 ms 16984 KB Output is correct
36 Correct 4 ms 16988 KB Output is correct
37 Correct 4 ms 16988 KB Output is correct
38 Correct 4 ms 17084 KB Output is correct
39 Correct 60 ms 26964 KB Output is correct
40 Correct 50 ms 27216 KB Output is correct
41 Correct 38 ms 26876 KB Output is correct
42 Correct 37 ms 26964 KB Output is correct
43 Correct 44 ms 27288 KB Output is correct
44 Correct 37 ms 27216 KB Output is correct
45 Correct 50 ms 20560 KB Output is correct
46 Correct 69 ms 20444 KB Output is correct
47 Correct 43 ms 26932 KB Output is correct
48 Correct 43 ms 26964 KB Output is correct
49 Correct 42 ms 26964 KB Output is correct
50 Correct 41 ms 26972 KB Output is correct
51 Correct 61 ms 26716 KB Output is correct
52 Correct 79 ms 27216 KB Output is correct
53 Correct 38 ms 27484 KB Output is correct
54 Correct 38 ms 27724 KB Output is correct
55 Correct 141 ms 26956 KB Output is correct
56 Correct 118 ms 26708 KB Output is correct
57 Correct 59 ms 20224 KB Output is correct
58 Correct 90 ms 20572 KB Output is correct
59 Correct 185 ms 27216 KB Output is correct
60 Correct 170 ms 27236 KB Output is correct
61 Correct 153 ms 27180 KB Output is correct
62 Correct 182 ms 27220 KB Output is correct
63 Correct 165 ms 27220 KB Output is correct
64 Correct 167 ms 27200 KB Output is correct
65 Correct 105 ms 26444 KB Output is correct
66 Correct 125 ms 26708 KB Output is correct
67 Correct 103 ms 26196 KB Output is correct
68 Correct 106 ms 26612 KB Output is correct
69 Correct 158 ms 26976 KB Output is correct
70 Correct 151 ms 27216 KB Output is correct
71 Correct 44 ms 26972 KB Output is correct
72 Correct 41 ms 27740 KB Output is correct
73 Correct 181 ms 27908 KB Output is correct
74 Correct 244 ms 28240 KB Output is correct
75 Correct 236 ms 28448 KB Output is correct
76 Correct 125 ms 27228 KB Output is correct
77 Correct 181 ms 27988 KB Output is correct
78 Correct 250 ms 28440 KB Output is correct
79 Correct 104 ms 21360 KB Output is correct
80 Correct 141 ms 21340 KB Output is correct
81 Correct 139 ms 27452 KB Output is correct
82 Correct 86 ms 26712 KB Output is correct
83 Correct 168 ms 27728 KB Output is correct
84 Correct 169 ms 27736 KB Output is correct
85 Correct 141 ms 27216 KB Output is correct
86 Correct 170 ms 27752 KB Output is correct
87 Correct 131 ms 27476 KB Output is correct
88 Correct 184 ms 27984 KB Output is correct
89 Correct 88 ms 24364 KB Output is correct
90 Correct 184 ms 27732 KB Output is correct
91 Correct 112 ms 26960 KB Output is correct
92 Correct 104 ms 26704 KB Output is correct
93 Correct 166 ms 27728 KB Output is correct
94 Correct 168 ms 27732 KB Output is correct
95 Correct 163 ms 27476 KB Output is correct
96 Correct 160 ms 27728 KB Output is correct
97 Correct 193 ms 27732 KB Output is correct
98 Correct 120 ms 26972 KB Output is correct
99 Correct 115 ms 26920 KB Output is correct
100 Correct 98 ms 26704 KB Output is correct
101 Correct 127 ms 27216 KB Output is correct
102 Correct 112 ms 27848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 16988 KB Output is correct
2 Correct 3 ms 16988 KB Output is correct
3 Correct 4 ms 16988 KB Output is correct
4 Correct 4 ms 16988 KB Output is correct
5 Correct 3 ms 16812 KB Output is correct
6 Correct 4 ms 16732 KB Output is correct
7 Correct 3 ms 16988 KB Output is correct
8 Correct 4 ms 16988 KB Output is correct
9 Correct 4 ms 16988 KB Output is correct
10 Correct 4 ms 16984 KB Output is correct
11 Correct 4 ms 16984 KB Output is correct
12 Correct 4 ms 16988 KB Output is correct
13 Correct 3 ms 16828 KB Output is correct
14 Correct 3 ms 16988 KB Output is correct
15 Correct 3 ms 16988 KB Output is correct
16 Correct 4 ms 16988 KB Output is correct
17 Correct 4 ms 16988 KB Output is correct
18 Correct 4 ms 16988 KB Output is correct
19 Correct 4 ms 16988 KB Output is correct
20 Correct 4 ms 17044 KB Output is correct
21 Correct 5 ms 16988 KB Output is correct
22 Correct 4 ms 16988 KB Output is correct
23 Correct 4 ms 16984 KB Output is correct
24 Correct 4 ms 16988 KB Output is correct
25 Correct 4 ms 16728 KB Output is correct
26 Correct 3 ms 16988 KB Output is correct
27 Correct 4 ms 16988 KB Output is correct
28 Correct 6 ms 16988 KB Output is correct
29 Correct 4 ms 16988 KB Output is correct
30 Correct 6 ms 17096 KB Output is correct
31 Correct 6 ms 17036 KB Output is correct
32 Correct 6 ms 16988 KB Output is correct
33 Correct 3 ms 16988 KB Output is correct
34 Correct 3 ms 17068 KB Output is correct
35 Correct 5 ms 16984 KB Output is correct
36 Correct 4 ms 16988 KB Output is correct
37 Correct 4 ms 16988 KB Output is correct
38 Correct 4 ms 17084 KB Output is correct
39 Correct 60 ms 26964 KB Output is correct
40 Correct 50 ms 27216 KB Output is correct
41 Correct 38 ms 26876 KB Output is correct
42 Correct 37 ms 26964 KB Output is correct
43 Correct 44 ms 27288 KB Output is correct
44 Correct 37 ms 27216 KB Output is correct
45 Correct 50 ms 20560 KB Output is correct
46 Correct 69 ms 20444 KB Output is correct
47 Correct 43 ms 26932 KB Output is correct
48 Correct 43 ms 26964 KB Output is correct
49 Correct 42 ms 26964 KB Output is correct
50 Correct 41 ms 26972 KB Output is correct
51 Correct 61 ms 26716 KB Output is correct
52 Correct 79 ms 27216 KB Output is correct
53 Correct 38 ms 27484 KB Output is correct
54 Correct 38 ms 27724 KB Output is correct
55 Execution timed out 1074 ms 45660 KB Time limit exceeded
56 Halted 0 ms 0 KB -