結果

問題 No.73 helloworld
ユーザー YamaKasaYamaKasa
提出日時 2018-07-01 00:23:50
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,419 bytes
コンパイル時間 2,052 ms
コンパイル使用メモリ 73,728 KB
実行使用メモリ 56,328 KB
最終ジャッジ日時 2023-09-13 16:26:48
合計ジャッジ時間 4,783 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,736 KB
testcase_01 AC 124 ms
55,636 KB
testcase_02 AC 127 ms
55,956 KB
testcase_03 AC 126 ms
55,840 KB
testcase_04 AC 124 ms
56,328 KB
testcase_05 AC 126 ms
55,940 KB
testcase_06 AC 124 ms
55,636 KB
testcase_07 AC 124 ms
56,156 KB
testcase_08 AC 124 ms
56,016 KB
testcase_09 AC 126 ms
55,660 KB
testcase_10 AC 126 ms
55,884 KB
testcase_11 WA -
testcase_12 AC 123 ms
55,916 KB
testcase_13 AC 123 ms
55,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[] C = new int[26];
		for(int i = 0; i < 26; i++) {
			C[i] = scan.nextInt();
		}
		scan.close();

		// d  e  h  l  o  r  w
		// 3  4  7  11 14 17   22

		long ans = C[3] * C[4] * C[7] * C[17] * C[22];

		long max1 = 0;
		for(int i = 2; i < C[11]; i++) {
			long t = comb(i, 2) * (C[11] - i);
			max1 = Math.max(max1, t);
		}

		long max2 = 0;
		for(int i = 1; i < C[14]; i++) {
			long t = i * (C[14] - i);
			max2 = Math.max(max2, t);
		}
		ans = ans * max1 * max2;
		System.out.println(ans);
	}

	public static long comb(int n, int r) {
        if (n - r < r) r = n - r;
        if (r == 0) return 1;
        if (r == 1) return n;
        int[] num = new int[r];
        int[] den = new int[r];
        for (int k = 0; k < r; k++){
            num[k] = n - r + k + 1;
            den[k] = k + 1;
        }
        for (int p = 2; p <= r; p++) {
            int pivot = den[p - 1];
            if (pivot > 1) {
                int offset = (n - r) % p;
                for (int k = p - 1; k < r; k += p) {
                    num[k - offset] /= pivot;
                    den[k] /= pivot;
                }
            }
        }
        long result = 1;
        for (int k = 0; k < r; k++) {
            if (num[k] > 1) result *= num[k];
        }
        return result;
    }

}
0