https://www.acmicpc.net/problem/1149
---------------------------------------------
import java.util.Scanner;
public class Main {
static int[] array = new int[3];
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
int input = scanner.nextInt();
for (int i = 0; i < input; i++) {
setNext(scanner.nextInt(), scanner.nextInt(), scanner.nextInt());
}
int result = array[0] < array[1] ? array[0] : array[1];
result = result < array[2] ? result : array[2];
System.out.println(result);
scanner.close();
}
static void setNext(int temp0, int temp1, int temp2) {
int[] temp = new int[3];
temp[0] = temp0 + (array[1] < array[2] ? array[1] : array[2]);
temp[1] = temp1 + (array[0] < array[2] ? array[0] : array[2]);
temp[2] = temp2 + (array[0] < array[1] ? array[0] : array[1]);
array = temp;
}
}
'코딩 테스트 > 백준(java)' 카테고리의 다른 글
Q14891번: 톱니바퀴 (0) | 2021.03.20 |
---|---|
Q14890: 경사로 (0) | 2021.03.20 |
백준 2193) 이친수 (0) | 2017.09.16 |
백준 1003) 피보나치 함수 (0) | 2017.09.16 |
백준 1463) 1로 만들기 (0) | 2017.09.16 |