BOJ 24511 queuestack

1 개요[ | ]

BOJ 24511 queuestack


2 C++[ | ]

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N, temp;
    cin >> N;

    vector<int> v;
    deque<int> q;
    for(int i=0; i<N; i++) {
        cin >> temp;
        v.push_back(temp);
    }
    for(int i=0; i<N; i++) {
        cin >> temp;
        if(v[i]) continue;
        q.push_front(temp);
    }
    
    int M;
    cin >> M;
    for(int i=0; i<M; i++) {
        cin >> temp;
        q.push_back(temp);
        cout << q.front() << ' ';
        q.pop_front();
    }
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}