結果

問題 No.227 簡単ポーカー
ユーザー fkwnw3_1243fkwnw3_1243
提出日時 2017-04-30 17:20:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 59 ms / 5,000 ms
コード長 1,430 bytes
コンパイル時間 2,444 ms
コンパイル使用メモリ 83,496 KB
実行使用メモリ 50,904 KB
最終ジャッジ日時 2023-10-11 23:50:41
合計ジャッジ時間 4,418 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
50,432 KB
testcase_01 AC 57 ms
50,556 KB
testcase_02 AC 57 ms
50,568 KB
testcase_03 AC 58 ms
50,428 KB
testcase_04 AC 57 ms
50,576 KB
testcase_05 AC 58 ms
50,888 KB
testcase_06 AC 55 ms
50,560 KB
testcase_07 AC 58 ms
50,572 KB
testcase_08 AC 59 ms
50,904 KB
testcase_09 AC 59 ms
50,552 KB
testcase_10 AC 59 ms
50,576 KB
testcase_11 AC 58 ms
50,696 KB
testcase_12 AC 56 ms
50,412 KB
testcase_13 AC 57 ms
50,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

import static java.lang.System.in;


public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String[] inputs = reader.readLine().split(" ");
        int[] cards = Stream.of(inputs).mapToInt(Integer::parseInt).toArray();
        int[] table = new int[13];
        for (int i = 0; i < 5; i++) {
            table[cards[i] - 1] += 1;
        }
        tellPokerHands(table);
    }

    private static void tellPokerHands(int[] table) {
        List<Integer> pairs = new ArrayList<>();
        int triple = -1;

        for (int i = 0; i < 13; i++) {
            if (table[i] == 3) {
                triple = i;
            } else if (table[i] == 2) {
                pairs.add(i);
            }
        }

        if(triple!=-1 && pairs.size()==1) {
            System.out.println("FULL HOUSE");
        } else if (triple != -1) {
            System.out.println("THREE CARD");
        } else if (pairs.size()==2){
            System.out.println("TWO PAIR");
        } else if (pairs.size()==1){
            System.out.println("ONE PAIR");
        } else {
            System.out.println("NO HAND");
        }
    }
}
0