結果

問題 No.73 helloworld
ユーザー kano_townkano_town
提出日時 2014-11-21 10:31:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 132 ms / 5,000 ms
コード長 990 bytes
コンパイル時間 3,422 ms
コンパイル使用メモリ 79,664 KB
実行使用メモリ 56,228 KB
最終ジャッジ日時 2023-09-11 07:27:59
合計ジャッジ時間 6,139 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
55,956 KB
testcase_01 AC 127 ms
55,968 KB
testcase_02 AC 130 ms
55,788 KB
testcase_03 AC 129 ms
55,792 KB
testcase_04 AC 129 ms
55,760 KB
testcase_05 AC 129 ms
55,908 KB
testcase_06 AC 130 ms
56,228 KB
testcase_07 AC 130 ms
56,040 KB
testcase_08 AC 130 ms
55,840 KB
testcase_09 AC 129 ms
55,784 KB
testcase_10 AC 131 ms
55,800 KB
testcase_11 AC 132 ms
55,828 KB
testcase_12 AC 130 ms
55,512 KB
testcase_13 AC 128 ms
55,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Yukicoder73 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] alpha = new int[26];
		for (int i = 0; i < 26; i++) alpha[i] = sc.nextInt();

		long maxH = -1, maxO, res = 0;

		if (alpha['h' - 'a'] > 0 && alpha['e' - 'a'] > 0 && alpha['l' - 'a'] > 2 && alpha['o' - 'a'] > 1 && alpha['w' - 'a'] > 0 && alpha['r' - 'a'] > 0 && alpha['d' - 'a'] > 0) {
			for (int i = 2; i < alpha['l' - 'a']; i++) maxH = Math.max(cmb(i, 2) * (alpha['l' - 'a'] - i), maxH);
			maxO = (long) (Math.ceil(alpha['o' - 'a'] / 2.0) * Math.floor(alpha['o' - 'a'] / 2.0));
			res = maxH * maxO * alpha['h' - 'a'] * alpha['e' - 'a'] * alpha['w' - 'a'] * alpha['r' - 'a'] * alpha['d' - 'a'];
		}

		System.out.println(res);
	}

	static long cmb(int n, int m) {
		long c = 1;
		m = (n - m < m ? n - m : m);
		for (int ns = n - m + 1, ms = 1; ms <= m; ns++, ms++) {
			c *= ns;
			c /= ms;
		}
		return c;
	}
}
0