백준 2476 java

magicdrill·2024년 9월 13일
0

백준 문제풀이

목록 보기
438/654

백준 2476 java

import java.util.Collection;
import java.util.Collections;
import java.util.Scanner;
import java.util.Vector;

public class bj2476 {
    public static void main(String[] args) {
        Vector<Vector<Integer>> dice = new Vector<>();

        dice = inputData();
        findAnswer(dice);
    }

    public static Vector<Vector<Integer>> inputData(){
        Scanner scanner = new Scanner(System.in);
        Vector<Vector<Integer>> dice = new Vector<>();
        int N, i, j, diceNum;

        N = scanner.nextInt();
        for(i = 0; i < N; i++) {
            Vector<Integer> temp = new Vector<>();

            for (j = 0; j < 3; j++) {
                diceNum = scanner.nextInt();
                temp.add(diceNum);
            }
            dice.add(temp);
        }
        scanner.close();

        return dice;
    }

    public static void findAnswer(Vector<Vector<Integer>> dice)
    {
        int i, j, sum = 0, max = 0;
        int a, b, c;

        for(i = 0; i < dice.size(); i++)
        {
            Vector<Integer> temp = dice.get(i);

            Collections.sort(temp);
            a = temp.get(0);
            b = temp.get(1);
            c = temp.get(2);
            if(a == b && b == c)
            {
                sum = 10000 + (c * 1000);
            }
            else if(a != b && b != c && a != c)
            {
                sum = c * 100;
            }
            else
            {
                if (a == b || a == c)
                {
                    sum = 1000 + (a * 100);
                }
                else
                {
                    sum = 1000 + (b * 100);
                }
            }
            if(sum > max)
            {
                max = sum;
            }
        }
        System.out.println(max);
    }
}

0개의 댓글