x;multiset<int>s;queue<int>smallest;for(inti=1;i<=n;i++){// O(n)cin>>op;if(op==1){cin>>x;s.insert(x);// O(n log n)smallest.push(x);}elseif(op==2){if(!smallest.empty()){cout<<smallest.front()<<"\n";autopos=s.find(smallest.front());// O(log n)s.erase(pos...
一个集合允许你按照sorting顺序完全访问,例如,你可以在集合的中间find两个元素,然后按照从一个到另一个的顺序遍历。 set / multiset通常由二叉树支持。 http://en.wikipedia.org/wiki/Binary_tree priority_queue通常由一个堆支持。 http://en.wikipedia.org/wiki/Heap_(data_structure); 所以问题是什么时候应...