제출 #994978

#제출 시각아이디문제언어결과실행 시간메모리
994978snpmrnhlol푸드 코트 (JOI21_foodcourt)C++17
컴파일 에러
0 ms0 KiB
#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]; ll fen[N + 1]; 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){ ll coef; if(ok[pos])coef = -updates2[pos].second; else coef = updates2[pos].second; ok[pos]^=1; for(ll i = pos + 1;i <= updcnt;i+=(i&-i)){ fen[i]+=coef; } } ll get2(ll x){ ll pos = 0,sum = 0; for(ll i = (1<<20);i > 0;i/=2){ if(pos + i <= updcnt && sum + fen[pos + i] < x){ sum+=fen[pos + i]; pos+=i; } } //cout<<updates2[0].first<<' '<<updates2[1].first<<' '<<updates2[2].first<<' '<<pos<<'\n'; return updates2[pos].first; } ll 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 **/

컴파일 시 표준 에러 (stderr) 메시지

foodcourt.cpp:87:1: error: '::main' must return 'int'
   87 | ll main(){
      | ^~