Codeforces 527C Glass Carving (set+multiset)
2017-08-21 12:50
435 查看
对于一个矩形,宽为w,高为h。现在对其进行一系列的切割。让你求出每次切割后的最大面积的矩形
参考http://blog.csdn.net/u011580493/article/details/44457477
学习了下multiset。。
没想到STL那么好用
参考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)); } }
相关文章推荐
- CodeForces 527C:Glass Carving (set与multiset应用)
- Codeforces 527C Glass Carving<set集合和multiset集合的使用>
- CodeForces 527C - Glass Carving set multiset 二分
- CodeForces 674 D.Bearish Fanpages(set+multiset)
- 【codeforces 796C】Bank Hacking(用一些技巧来代替multiset)
- 容器set和multiset
- STL源码:hash_set、hash_map、hash_multiset、hash_multimap
- Codeforces 34C-Page Numbers(set+vector+暴力乱搞)
- C++的STL之set/multiset
- codeforces 675D Tree Construction set
- CodeForces 831C Jury Marks(set)
- STL笔记(4)-set/multiset,functor,pair的使用方法
- STL之set&multiset使用简介
- Codeforces 274A:k-Multiple Free Set(初识set集合)
- codeforces-752【A找规律】【set+pair】
- C++ STL学习之容器set和multiset (补充材料)
- STL:set/multiset用法详解
- STL容器Set和Multiset
- STL中set与multiset的区别
- Codeforces 245G Suggested Friends - 交集set_intersection()