알고리즘/해시

[백준] 2480번 주사위 세개 #Java

VIPeveloper 2022. 5. 29. 16:38
728x90
반응형
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        TreeMap<Integer,Integer> hashMap = new TreeMap<>();
        StringTokenizer st = new StringTokenizer(br.readLine()," ");
        for (int i = 0; i < 3; i++) {
            int a = Integer.parseInt(st.nextToken());
            hashMap.put(a,hashMap.getOrDefault(a,0)+1);
        }
        if(hashMap.size()==3){
            System.out.println(hashMap.lastKey() * 100);
        }else if(hashMap.size()==2){
            for (Map.Entry m : hashMap.entrySet()){
                int value = (int) m.getValue();
                if(value ==2){
                    System.out.println(1000 + ((int) m.getKey() * 100));
                }
            }
        }else{
            System.out.println(10000 + (hashMap.firstKey() * 1000));
        }
    }
}
728x90
반응형