
package test;
import java.io.IOException;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
int test = 10;
for (int k = 0; k < test; k++) {
int testcase = sc.nextInt();
int[] array = new int[8];
int count=1;
int temp=0;
for(int i=0; i<8; i++) {
array[i] = sc.nextInt();
}
while(array[7]>0) {
if(count>5) {
count=1;
}else {
temp = array[0];
for(int i=0; i<7; i++) {
array[i]=array[i+1];
}
if(temp-count<0) {
array[7]=0;
}else {
array[7]=temp-count;
}
count++;
}
}
System.out.print("#" + (k + 1) + " " );
for(int i=0; i<8; i++) {
System.out.print(array[i]+" ");
}
System.out.println();
}
}
}
배열의 순서를 바꿔주고, 5를 초과하여 빼주지 않게 조건을 걸어줬다.
'알고리즘(종합) > Lv.3' 카테고리의 다른 글
1215 - 회문1 (0) | 2022.11.19 |
---|---|
2805 - 농작물 수확하기 (0) | 2022.11.18 |
1209 - sum (0) | 2022.11.18 |
1208 - Flatten (0) | 2022.11.17 |
1244. 최대 상금 (0) | 2022.11.16 |