BOJ 24511 queuestack

Jmnote (토론 | 기여)님의 2023년 9월 9일 (토) 01:42 판
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

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 }}