"BOJ 24511 queuestack"의 두 판 사이의 차이

(새 문서: ==개요== {{BOJ|단계=16}})
 
 
1번째 줄: 1번째 줄:
==개요==
==개요==
{{BOJ|단계=16}}
{{BOJ|단계=16}}
==C++==
<syntaxhighlight lang='cpp'>
#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();
    }
}
</syntaxhighlight>

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