結果

問題 No.227 簡単ポーカー
ユーザー tentententen
提出日時 2020-12-09 18:57:01
言語 Java21
(openjdk 21)
結果
AC  
実行時間 140 ms / 5,000 ms
コード長 907 bytes
コンパイル時間 2,919 ms
コンパイル使用メモリ 75,796 KB
実行使用メモリ 57,536 KB
最終ジャッジ日時 2023-10-19 05:31:05
合計ジャッジ時間 4,984 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
57,444 KB
testcase_01 AC 140 ms
57,376 KB
testcase_02 AC 138 ms
57,368 KB
testcase_03 AC 137 ms
57,500 KB
testcase_04 AC 135 ms
57,484 KB
testcase_05 AC 136 ms
57,440 KB
testcase_06 AC 137 ms
57,404 KB
testcase_07 AC 136 ms
57,340 KB
testcase_08 AC 137 ms
57,380 KB
testcase_09 AC 139 ms
57,328 KB
testcase_10 AC 134 ms
57,408 KB
testcase_11 AC 134 ms
57,536 KB
testcase_12 AC 136 ms
57,328 KB
testcase_13 AC 137 ms
57,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < 5; i++) {
            int x = sc.nextInt();
            map.put(x, map.getOrDefault(x, 0) + 1);
        }
        int three = 0;
        int two = 0;
        for (int x : map.values()) {
            if (x == 3) {
                three++;
            } else if (x == 2) {
                two++;
            }
        }
        String ans;
        if (three == 1 && two == 1) {
            ans = "FULL HOUSE";
        } else if (three == 1) {
            ans = "THREE CARD";
        } else if (two == 2) {
            ans = "TWO PAIR";
        } else if (two == 1) {
            ans = "ONE PAIR";
        } else {
            ans = "NO HAND";
        }
        System.out.println(ans);
    }
}
0