Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
Tags
- boole_d
- APPENDING
- FOR ALL ENTRIES IN
- SAP
- DP - 유한배낭
- transporting
- Data Browser
- java
- DP - 무한배낭(순서)
- using value
- NEW-PAGE PRINT ON
- qfieldname
- READ TABLE
- SAP GUI
- ZPL
- ALV Output Setting
- APPENDING CORRESPONDING
- CTS #CTS 이관 #SAP #ABAP
- DP - 무한배낭
- batch job
- Dictionary Search Help
- changing value
- 필드카탈로그
- MONAT_F4
- Union-Find
- cfieldname
- BOJ_Gold
- ABAP
- SM36
- 날짜 계산 함수
Archives
- Today
- Total
Jin's Library
[Silver Ⅲ] 2346 - 풍선 터뜨리기 본문
package BOJ.Silver;
import java.util.*;
// 실버 3 풍선 터뜨리기
public class BOJ_2346 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
List<Integer> balloon = new ArrayList<>();
StringBuffer answer = new StringBuffer();
for(int i=1;i<=N;i++)
balloon.add(sc.nextInt());
sc.close();
int move = 0, cursor = 0;
for(int i=0;i<N;i++){
int direction = (move < 0) ? -1 : 1;
move *= direction;
for(int j=0;j<move;j++){
cursor += direction;
if(cursor >= N) cursor = 0;
else if(cursor < 0) cursor = N-1;
if(balloon.get(cursor) == 0) j--;
}
move = balloon.get(cursor);
balloon.set(cursor, 0);
answer.append(cursor+1+" ");
}
System.out.println(answer.toString());
}
}'Algorithm - Java > BOJ - Silver' 카테고리의 다른 글
| [Silver Ⅳ] 4949 - 균형잡힌 세상 (0) | 2025.10.17 |
|---|---|
| [Sliver Ⅱ] 10799 - 쇠막대기 (0) | 2025.10.17 |
| [Silver Ⅴ] 2941 - 크로아티아 알파벳 (0) | 2025.09.30 |
| [Silver Ⅴ] 7785 - 회사에 있는 사람 (0) | 2025.09.30 |
| [Silver Ⅳ] 9012 - 괄호 (0) | 2025.09.30 |