插入,删除,取最小

 


 

方法0:STL 优先队列

1198ms

 

#include<iostream>
#include<cstdio>
#include<queue>
#include<vector> 
using namespace std;
inline int read(){
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1; c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0'; c=getchar();}
    return x*f;
}
int n,op;
priority_queue<int, vector<int>, greater<int> > q;
int main(){
    //freopen("in.txt","r",stdin);
    n=read();
    for(int i=1;i<=n;i++){
        op=read();
        if(op==1) q.push(read());
        else if(op==2) printf("%d\n",q.top());
        else q.pop();
    }
}
View Code

相关文章:

  • 2022-01-07
  • 2022-12-23
  • 2021-11-19
  • 2022-02-09
  • 2022-12-23
  • 2021-09-15
  • 2021-12-13
猜你喜欢
  • 2021-11-30
  • 2022-12-23
  • 2022-12-23
  • 2021-08-15
  • 2021-10-07
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案