您的位置:首页 > 其它

Codeforces 527C Glass Carving (set+multiset)

2017-08-21 12:50 435 查看
对于一个矩形,宽为w,高为h。现在对其进行一系列的切割。让你求出每次切割后的最大面积的矩形

参考http://blog.csdn.net/u011580493/article/details/44457477

学习了下multiset。。

没想到STL那么好用

LL w,h,n;
set<LL>st[2];
multiset<LL>mst[2];
LL solve(int sta,int val){
set<LL>::iterator it;
it=st[sta].lower_bound(val);
LL v1=*it,v2=*(--it);
mst[sta].erase(mst[sta].find(v1-v2));
st[sta].insert(val);
mst[sta].insert(v1-val);
mst[sta].insert(val-v2);
return ((*mst[sta].rbegin())*(*mst[sta^1].rbegin()));
}
int main(){
sf("%lld%lld%lld",&w,&h,&n);
st[0].insert(0),st[0].insert(w);
st[1].insert(0),st[1].insert(h);
mst[0].insert(w),mst[1].insert(h);
rep(i,1,n){
getchar();
char s;int d;sf("%c %d",&s,&d);
pf("%lld\n",s=='H'?solve(1,d):solve(0,d));
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: