VioletaBabel

2346번: 풍선 터뜨리기 (실패) 본문

백준/백준-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;

}

}

}


==========시간초과.

'백준 > 백준-C++' 카테고리의 다른 글

10815번: 숫자 카드  (0) 2017.06.05
10867번: 중복 빼고 정렬하기  (0) 2017.06.05
2618번: 경찰차 (실패)  (0) 2017.06.05
11816번: 8진수, 10진수, 16진수  (0) 2017.06.04
6359번: 만취한 상범  (0) 2017.06.04
Comments