https://swexpertacademy.com/main/main.do
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
Queue를 사용해서 쉽게 풀 수 있었던 문제
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class P1225 {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int T = 1;
for(int t=1; t<=T; t++){
int tc = sc.nextInt();
Queue<Integer> q = new LinkedList<>();
for(int i=0; i<8; i++){
q.offer(sc.nextInt());
}
for(int i=1; i<=5; i++){
int x = q.poll()-i;
if(x<=0){
q.add(0);
break;
} else q.add(x);
if(i==5){
i=0;
}
}
System.out.print("#"+tc+" ");
for(int k : q) System.out.print(k+" ");
System.out.println();
}
}
}
'알고리즘 > SWEA' 카테고리의 다른 글
[SWEA] 1213. [S/W 문제해결 기본] 3일차 - String (0) | 2022.11.10 |
---|---|
[SWEA] 1240. [S/W 문제해결 응용] 1일차 - 단순 2진 암호코드 (0) | 2022.11.10 |
[SWEA] 1216. [S/W 문제해결 기본] 3일차 - 회문2 (0) | 2022.11.10 |
[SWEA] 2805. 농작물 수확하기 (0) | 2022.11.09 |
[SWEA] 1244. [S/W 문제해결 응용] 2일차 - 최대 상금 (0) | 2022.11.09 |