10分求纠错

P3378 【模板】堆

@[rose\_](/space/show?uid=51621) c++······
by marshal王子祥 @ 2017-12-24 17:40:25


你可以调用STL......然后再switch......
by ycwDP @ 2017-12-24 19:37:19


呀!万能库!!!
by ycwDP @ 2017-12-24 19:38:15


@[闫子恒](/space/show?uid=35580) @[marshal王子祥](/space/show?uid=75742) 哦。你们是对的。优先队列就能过。 已ac,谢谢。 ```cpp #include <iostream> #include <stdio.h> #include <cmath> #include <queue> #include <map> #include <vector> #include <cstdlib> #include <utility> #include <algorithm> using namespace std; priority_queue<int,vector<int>,greater<int> > q; int n,x,a; int main(){ ios::sync_with_stdio(false); cin>>n; for (int i=1;i<=n;i++){ cin>>x; switch (x){ case 1:cin>>a; q.push(a); break; case 2:cout<<q.top()<<endl; break; case 3:q.pop(); break; default: break; } } return 0; } ```
by Altria_Pendragon_ @ 2017-12-27 10:11:26


|