BOJ 2346 풍선 터뜨리기

1 개요[ | ]

BOJ 2346 풍선 터뜨리기


2 C++[ | ]

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

int main() {
    int N, temp, i;
    cin >> N;

    deque<pair<int,int>> q;
    for(i=1; i<=N; i++) {
        cin >> temp;
        q.push_back({i,temp});
    }
    while(!q.empty()) {
        auto el = q.front();
        cout << el.first << ' ';
        temp = el.second;
        q.pop_front();
        if(temp > 0) {
            for(i=0; i<temp-1; i++) {
                q.push_back(q.front());
                q.pop_front();
            }
        } else {
            for(i=0; i>temp; i--) {
                q.push_front(q.back());
                q.pop_back();
            }
        }
    }
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}