题解 | #明明的随机数#

明明的随机数

http://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0

#include <iostream>
#include <queue>
#include <stack>
#include <vector>

using namespace std;

int main(){
    int N = 0;
    cin>>N;
    
    priority_queue<int> pq;
    
    for(int i = 0; i < N; i++){
        int num = 0;
        cin>>num;
        pq.push(num);
    }
    
    stack<int> st;
    st.push(pq.top());
    pq.pop();
    while(!pq.empty()){
        if(st.top() != pq.top()){
            st.push(pq.top());
        }
        pq.pop();
    }
    
    vector<int> res;
    while(!st.empty()){
        res.push_back(st.top());
        st.pop();
    }
    
    for(int i = 0; i < res.size(); i++){
        cout << res[i] << endl;
    }
    
    return 0;
}
华为题库题解 文章被收录于专栏

牛客华为题库的题解

全部评论

相关推荐

07-16 14:10
门头沟学院 Java
点赞 评论 收藏
分享
06-08 22:25
门头沟学院 Java
从零开始的转码生活:这hr不会打开手机不分青红皂白给所有人群发这句话,过一会再给所有人再发一遍,这肯定会有重复的,不管,再过一会再发一遍
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务