제출 #440419

#제출 시각아이디문제언어결과실행 시간메모리
440419i_am_noob사탕 분배 (IOI21_candies)C++17
29 / 100
608 ms15368 KiB
#include "candies.h" #include<bits/stdc++.h> using namespace std; #define ll long long //#define int ll #define rep(n) rep1(i,n) #define rep1(i,n) rep2(i,0,n) #define rep2(i,a,b) for(int i=a; i<(b); ++i) #define rep3(i,a,b) for(int i=a; i>=(b); --i) #define chkmax(a,b) (a=max(a,b)) #define chkmin(a,b) (a=min(a,b)) #define sz(a) ((int)a.size()) #define all(a) a.begin(),a.end() #define pb push_back #define pii pair<int,int> #define pow2(x) (1ll<<(x)) #ifdef zisk #define bug(...) cerr << "#" << __LINE__ << ": " << #__VA_ARGS__ << "- ", _do(__VA_ARGS__) template<typename T> void _do(T x){cerr << x << endl;} template<typename T, typename ...S> void _do(T x, S... y){cerr << x << ", "; _do(y...);} #else #define bug(...) 49 #endif const int maxn=200005,K=490; int n,q,op[maxn/K+5],valb[maxn/K+5],vals[maxn]; int pos[maxn],cc[maxn]; vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) { n=sz(c); q=sz(l); vector<int> res(n); { int tmp[maxn]; rep(n) tmp[i]=i; sort(tmp,tmp+n,[&c](int i, int j){return c[i]<c[j];}); rep(n) pos[i]=tmp[i]; rep(n) cc[i]=c[tmp[i]]; } rep1(j,q){ bool flag=0; rep(n/K+1){ if(!flag){ int maxpos=min(n-1,i*K+K-1); int tmp=vals[maxpos]; if(op[i]==1) tmp=cc[maxpos]; if(op[i]==-1) tmp=0; tmp+=valb[i]+v[j]; if(tmp>0&&tmp<cc[maxpos]){ bug(j,i); for(int k=i*K; k<min(n,(i+1)*K); ++k){ if(op[i]==1) vals[k]=cc[k]; if(op[i]==-1) vals[k]=0; vals[k]+=valb[i]+v[j]; chkmin(vals[k],cc[k]); chkmax(vals[k],0); } flag=1; op[i]=0,valb[i]=0; continue; } } if(flag) valb[i]+=v[j]; else if(v[j]>0) op[i]=1,valb[i]=0; else op[i]=-1,valb[i]=0; } //rep(n/K+1) bug(op[i],valb[i]); //rep(n) bug(vals[i]); } rep(n){ if(op[i/K]==1) vals[i]=cc[i]; if(op[i/K]==-1) vals[i]=0; vals[i]+=valb[i/K]; chkmin(vals[i],cc[i]); chkmax(vals[i],0); res[pos[i]]=vals[i]; } return res; }

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

candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:23:18: warning: statement has no effect [-Wunused-value]
   23 | #define bug(...) 49
      |                  ^~
candies.cpp:52:6: note: in expansion of macro 'bug'
   52 |      bug(j,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...