結果

問題 No.662 スロットマシーン
ユーザー Grenache
提出日時 2018-03-11 23:43:37
言語 Java
(openjdk 23)
結果
AC  
実行時間 233 ms / 2,000 ms
コード長 1,754 bytes
コンパイル時間 3,969 ms
コンパイル使用メモリ 79,896 KB
実行使用メモリ 46,656 KB
最終ジャッジ日時 2024-10-15 04:20:35
合計ジャッジ時間 8,874 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

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