백준 c++ 14783 Eenie Meenie Miney Moe
14783 Eenie Meenie Miney Moe
문제풀이
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
void fast_io(void)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int main()
{
fast_io();
int n, l;
queue<int> q;
queue<int> r;
cin >> n >> l;
for (int i = 0; i < n; i++)
{
q.push(i + 1);
}
for (int i = 0; i < l; i++)
{
int a;
cin >> a;
r.push(a);
}
while (q.size() > 1)
{
for (int i = 0; i < r.front() - 1; i++)
{
q.push(q.front());
q.pop();
}
q.pop();
r.push(r.front());
r.pop();
}
cout << q.front();
}
큐 두개를 사용했다.
Author And Source
이 문제에 관하여(백준 c++ 14783 Eenie Meenie Miney Moe), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@jaranda/백준-c-14783-Eenie-Meenie-Miney-Moe저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)