백준/백준-C++
2346번: 풍선 터뜨리기 (실패)
Beabletoet
2017. 6. 5. 22:24
#include<cstdio>
int main()
{
int n, b[1001], boom[1001], arrow = 1, temp;
scanf("%d", &n);
for (int i = 1; i <= n; ++i)
{
scanf("%d", &b[i]);
boom[i] = 1;
}
while(1)
{
printf("%d ", arrow);
temp = b[arrow]; // 3
boom[arrow] = 0; // boom[1] = 0
while (temp != 0)
if (temp > 0)
{
--temp;
arrow = (arrow + 1 > n) ? arrow - n + 1 : arrow + 1;
if (!boom[arrow])
++temp;
}
else
{
++temp;
arrow = (arrow - 1 < 1) ? arrow + n - 1 : arrow - 1;
if (!boom[arrow])
--temp;
}
}
}
==========시간초과.