版本比较
题解:P8170 [eJOI 2021] Waterfront
正文
增加 5 行删除 5 行
21 行未改动2223242526262728293017 行未改动484950515252535455568 行未改动656667686969707172733 行未改动7778798081818283848520 行未改动10610710810911011011121 行未改动struct node{ int h,d,cnt,edh; bool operator < (const node &b) const{ return edh<b.edh; } }}a[10005],b[10005];inline int edh(node b){ return b.h+b.d*m-x*b.cnt;}17 行未改动 if(ncnt<k&&a[j].cnt&&a[j].h>=x){ int optcnt=min(min(k-ncnt,a[j].cnt),a[j].h/x); a[j].h-=x*optcnt,a[j].cnt-=optcnt; ncnt+=optcnt; allcnt-=optcnt; allcnt-=optcnt; } } if(allcnt>(m-i)*k) return 0; }8 行未改动 for(int i=1;i<=n;i++){ cin>>a[i].h>>a[i].d; a[i].edh=edh(a[i]); if(a[i].h>=x) Q2.push(a[i]); else Q1.push(a[i]); else Q1.push(a[i]); } for(int i=1;i<=m;i++){ while(!Q1.empty()&&nowh(Q1.top(),i)>=x){ Q2.push(Q1.top());3 行未改动 if(Q2.empty()) break; auto t=Q2.top(); Q2.pop(); t.cnt++; t.edh=edh(t); t.edh=edh(t); if(nowh(t,i)>=x) Q2.push(t); else Q1.push(t); } }20 行未改动 } } cout<<ans<<"\n"; return 0;} }```