結果

問題 No.412 花火大会
ユーザー pekempeypekempey
提出日時 2016-08-12 22:42:20
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 808 bytes
コンパイル時間 1,353 ms
コンパイル使用メモリ 162,644 KB
実行使用メモリ 11,776 KB
最終ジャッジ日時 2024-04-25 06:27:02
合計ジャッジ時間 2,156 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 4 ms
6,144 KB
testcase_06 AC 8 ms
11,520 KB
testcase_07 AC 8 ms
11,648 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 4 ms
5,376 KB
testcase_13 AC 4 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 8 ms
11,008 KB
testcase_19 AC 9 ms
11,520 KB
testcase_20 AC 9 ms
11,392 KB
testcase_21 AC 8 ms
11,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	int c[3];
	for (int i = 0; i < 3; i++) cin >> c[i];
	sort(c, c + 3);

	int n;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];

	static long long dp[33][33][33][33];
	dp[0][0][0][0] = 1;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= 30; j++) {
			for (int k = 0; k <= 30; k++) {
				for (int l = 0; l <= 30; l++) {
					int nj = j + (a[i] >= c[0]);
					int nk = k + (a[i] >= c[1]);
					int nl = l + (a[i] >= c[2]);
					dp[i + 1][j][k][l] += dp[i][j][k][l];
					dp[i + 1][nj][nk][nl] += dp[i][j][k][l];
				}
			}
		}
	}

	long long ans = 0;
	for (int j = 3; j <= 30; j++) {
		for (int k = 2; k <= 30; k++) {
			for (int l = 1; l <= 30; l++) {
				ans += dp[n][j][k][l];
			}
		}
	}
	cout << ans << endl;
}
0