제출 #748285

#제출 시각아이디문제언어결과실행 시간메모리
748285jamezzz새로운 문제 (POI11_met)C++17
24 / 100
1535 ms65536 KiB
#include <bits/stdc++.h> using namespace std; #define sf scanf #define pf printf #define pb push_back #define INF 1023456789 typedef long long ll; typedef vector<int> vi; struct node{ int s,e,m;ll v,lz; node *l,*r; node(int _s,int _e){ s=_s,e=_e,m=(s+e)>>1,v=0; if(s!=e)l=new node(s,m),r=new node(m+1,e); } void up(int x,int y,int nv){ if(s==x&&e==y){v+=nv;return;} if(y<=m)l->up(x,y,nv); else if(x>m)r->up(x,y,nv); else l->up(x,m,nv),r->up(m+1,y,nv); } ll qry(int x){ if(s==x&&e==x)return v; if(x<=m)return v+l->qry(x); else return v+r->qry(x); } }*rt; #define maxn 300005 int n,m,p[maxn],k,l[maxn],r[maxn],a[maxn],ans[maxn]; vi s[maxn]; int main(){ sf("%d%d",&n,&m); for(int i=1;i<=m;++i){ int o;sf("%d",&o); s[o].pb(i); } vi v; for(int i=1;i<=n;++i){ sf("%d",&p[i]); v.pb(i); ans[i]=-1; } sf("%d",&k); for(int i=1;i<=k;++i)sf("%d%d%d",&l[i],&r[i],&a[i]); queue<tuple<int,int,vi>> q; q.push({1,k,v}); int pv=INF; while(!q.empty()){ auto[lo,hi,v]=q.front(); q.pop(); if(lo>hi||v.empty())continue; int mid=(lo+hi)>>1; if(mid<pv)rt=new node(1,m),pv=0; while(pv<mid){ ++pv; if(l[pv]<=r[pv])rt->up(l[pv],r[pv],a[pv]); else rt->up(l[pv],m,a[pv]),rt->up(1,r[pv],a[pv]); } vi lv,rv; for(int x:v){ ll tot=0; for(int i:s[x]){ tot+=rt->qry(i); if(tot>=p[x])break; } if(tot>=p[x])lv.pb(x),ans[x]=mid; else rv.pb(x); } q.push({lo,mid-1,lv}); q.push({mid+1,hi,rv}); } for(int i=1;i<=n;++i){ if(ans[i]==-1)pf("NIE\n"); else pf("%d\n",ans[i]); } }

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

met.cpp: In function 'int main()':
met.cpp:37:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |  sf("%d%d",&n,&m);
      |    ^
met.cpp:39:11: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |   int o;sf("%d",&o);
      |           ^
met.cpp:44:5: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |   sf("%d",&p[i]);
      |     ^
met.cpp:48:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |  sf("%d",&k);
      |    ^
met.cpp:49:25: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |  for(int i=1;i<=k;++i)sf("%d%d%d",&l[i],&r[i],&a[i]);
      |                         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...