結果

問題 No.227 簡単ポーカー
ユーザー jimanojimano
提出日時 2018-01-13 16:39:58
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 849 bytes
コンパイル時間 5,521 ms
コンパイル使用メモリ 74,000 KB
実行使用メモリ 56,284 KB
最終ジャッジ日時 2023-08-25 15:47:44
合計ジャッジ時間 5,597 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 116 ms
56,196 KB
testcase_02 AC 113 ms
55,928 KB
testcase_03 AC 114 ms
56,016 KB
testcase_04 AC 113 ms
56,000 KB
testcase_05 AC 113 ms
56,060 KB
testcase_06 AC 114 ms
56,032 KB
testcase_07 AC 114 ms
55,848 KB
testcase_08 AC 112 ms
56,164 KB
testcase_09 AC 113 ms
55,908 KB
testcase_10 AC 115 ms
55,660 KB
testcase_11 AC 110 ms
53,736 KB
testcase_12 AC 114 ms
56,284 KB
testcase_13 AC 111 ms
55,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package me.yukicoder.lv1;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class No0227 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Map<String, Integer> cards = new HashMap<>();

		for (int i = 0; i < 5; i++) {
			String key = sc.next();
//			cards.computeIfPresent(key, (k, v) -> v + 1);
//			cards.putIfAbsent(key, 1);
			if (cards.containsKey(key)) {
				cards.put(key, cards.get(key) + 1);
			} else {
				cards.put(key, 1);
			}
		}

		System.out.println(judge(cards));
	}

	static String judge(Map<String, Integer> cards) {
		if (cards.size() == 2) {
			return "FULL HOUSE";
		}
		if (cards.containsValue(3)) {
			return "THREE CARD";
		}
		if (cards.size() == 3) {
			return "TWO PAIR";
		}
		if (cards.size() == 4) {
			return "ONE PAIR";
		}
		return "NO HAND";
	}
}
0