結果

問題 No.412 花火大会
ユーザー 37zigen37zigen
提出日時 2016-08-13 01:21:32
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 986 bytes
コンパイル時間 4,379 ms
コンパイル使用メモリ 74,056 KB
実行使用メモリ 56,720 KB
最終ジャッジ日時 2023-08-07 12:06:22
合計ジャッジ時間 6,710 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 119 ms
56,092 KB
testcase_03 AC 118 ms
56,720 KB
testcase_04 AC 118 ms
55,808 KB
testcase_05 AC 119 ms
55,920 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 119 ms
55,652 KB
testcase_09 AC 118 ms
55,880 KB
testcase_10 AC 117 ms
55,624 KB
testcase_11 AC 118 ms
55,628 KB
testcase_12 AC 120 ms
55,896 KB
testcase_13 AC 120 ms
55,728 KB
testcase_14 AC 118 ms
55,656 KB
testcase_15 AC 119 ms
54,036 KB
testcase_16 AC 119 ms
55,884 KB
testcase_17 AC 120 ms
55,564 KB
testcase_18 AC 123 ms
55,728 KB
testcase_19 AC 122 ms
55,804 KB
testcase_20 AC 122 ms
56,056 KB
testcase_21 AC 123 ms
55,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package No400番台;

import java.util.*;

public class Q412 {
	public static void main(String[] args) {
		new Q412().solver();
	}

	void solver() {
		Scanner sc = new Scanner(System.in);
		int[] demand = new int[3];
		for (int i = 0; i < 3; i++) {
			demand[i] = sc.nextInt();
		}
		int N = sc.nextInt();
		int[] E = new int[N];

		for (int i = 0; i < N; i++) {
			E[i] = sc.nextInt();
		}
		long[][] dp = new long[40][5];
		dp[0][0] = 1;
		for (int s_i = 0; s_i < N; s_i++) {
			for (int cond = 0; cond <= 3; cond++) {
				dp[s_i + 1][cond] += dp[s_i][cond];
				if (cond < 3 && E[s_i] >= demand[cond]) {
					dp[s_i + 1][cond + 1] += dp[s_i][cond];
				} else {
					dp[s_i + 1][cond] += dp[s_i][cond];
				}
			}
		}
		System.out.println(dp[N][3]);

	}

	static long nCk(int n, int k) {
		if (n < k)
			return 0;
		else {
			return (fact(n) / fact(n - k) / fact(k));
		}
	}

	static long fact(int n) {
		long ans = 1;
		for (int i = 1; i <= n; i++)
			ans *= i;
		return ans;
	}

}
0