版本比较
题解:P8170 [eJOI 2021] Waterfront
正文
增加 5 行删除 5 行
21 行未改动22232425262728293017 行未改动4849505152535455568 行未改动6566676869707172733 行未改动77787980818283848520 行未改动10610710810911011121 行未改动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;}}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]);}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);if(nowh(t,i)>=x) Q2.push(t);else Q1.push(t);}}20 行未改动}}cout<<ans<<"\n";return 0;}```21 行未改动22232425262728293017 行未改动4849505152535455568 行未改动6566676869707172733 行未改动77787980818283848520 行未改动10610710810911011121 行未改动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;}}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]);}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);if(nowh(t,i)>=x) Q2.push(t);else Q1.push(t);}}20 行未改动}}cout<<ans<<"\n";return 0;}```