結果

問題 No.662 スロットマシーン
ユーザー GrenacheGrenache
提出日時 2018-03-11 23:43:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 235 ms / 2,000 ms
コード長 1,754 bytes
コンパイル時間 3,616 ms
コンパイル使用メモリ 76,540 KB
実行使用メモリ 60,472 KB
最終ジャッジ日時 2023-08-05 06:37:01
合計ジャッジ時間 8,557 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
56,048 KB
testcase_01 AC 128 ms
55,948 KB
testcase_02 AC 136 ms
54,876 KB
testcase_03 AC 173 ms
56,836 KB
testcase_04 AC 180 ms
56,396 KB
testcase_05 AC 143 ms
56,736 KB
testcase_06 AC 187 ms
59,256 KB
testcase_07 AC 188 ms
58,932 KB
testcase_08 AC 212 ms
59,628 KB
testcase_09 AC 231 ms
60,028 KB
testcase_10 AC 233 ms
60,428 KB
testcase_11 AC 232 ms
59,848 KB
testcase_12 AC 231 ms
60,280 KB
testcase_13 AC 228 ms
59,628 KB
testcase_14 AC 228 ms
59,948 KB
testcase_15 AC 232 ms
59,772 KB
testcase_16 AC 126 ms
56,432 KB
testcase_17 AC 232 ms
60,000 KB
testcase_18 AC 235 ms
60,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder662 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		String[] str = new String[5];
		int[] coin = new int[5];
		for (int i = 0; i < 5; i++) {
			str[i] = sc.next();
			coin[i] = sc.nextInt();
		}

		int n1 = sc.nextInt();
		Map<String, Integer> hm1 = new HashMap<>();
		for (int i = 0; i < n1; i++) {
			String a = sc.next();
			if (hm1.containsKey(a)) {
				hm1.put(a, hm1.get(a) + 1);
			} else {
				hm1.put(a, 1);
			}
		}

		int n2 = sc.nextInt();
		Map<String, Integer> hm2 = new HashMap<>();
		for (int i = 0; i < n2; i++) {
			String a = sc.next();
			if (hm2.containsKey(a)) {
				hm2.put(a, hm2.get(a) + 1);
			} else {
				hm2.put(a, 1);
			}
		}

		int n3 = sc.nextInt();
		Map<String, Integer> hm3 = new HashMap<>();
		for (int i = 0; i < n3; i++) {
			String a = sc.next();
			if (hm3.containsKey(a)) {
				hm3.put(a, hm3.get(a) + 1);
			} else {
				hm3.put(a, 1);
			}
		}

		long ans = 0;
		long[] cnt = new long[5];
		for (int i = 0; i < 5; i++) {
			Integer tmp1 = hm1.get(str[i]);
			Integer tmp2 = hm2.get(str[i]);
			Integer tmp3 = hm3.get(str[i]);

			if (tmp1 == null || tmp2 == null || tmp3 == null) {
				continue;
			}

			cnt[i] += 5L * tmp1 * tmp2 * tmp3;
			ans += cnt[i] * coin[i];
		}

		pr.printf("%.2f\n", (double)ans / n1 / n2 / n3);
		for (int i = 0; i < 5; i++) {
			pr.println(cnt[i]);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0