結果

問題 No.1457 ツブ消ししとるなHard
ユーザー e869120e869120
提出日時 2021-03-31 21:17:46
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 897 bytes
コンパイル時間 730 ms
コンパイル使用メモリ 84,900 KB
実行使用メモリ 58,676 KB
最終ジャッジ日時 2023-08-21 22:24:29
合計ジャッジ時間 1,820 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
13,608 KB
testcase_01 AC 2 ms
5,500 KB
testcase_02 AC 3 ms
11,560 KB
testcase_03 AC 3 ms
9,576 KB
testcase_04 AC 24 ms
58,668 KB
testcase_05 AC 22 ms
56,748 KB
testcase_06 AC 24 ms
58,660 KB
testcase_07 AC 2 ms
5,408 KB
testcase_08 AC 2 ms
5,448 KB
testcase_09 AC 10 ms
32,028 KB
testcase_10 AC 11 ms
32,312 KB
testcase_11 AC 5 ms
15,664 KB
testcase_12 AC 23 ms
58,656 KB
testcase_13 AC 10 ms
32,308 KB
testcase_14 AC 10 ms
32,052 KB
testcase_15 AC 16 ms
46,376 KB
testcase_16 AC 23 ms
58,676 KB
testcase_17 AC 2 ms
5,464 KB
testcase_18 AC 2 ms
5,404 KB
testcase_19 AC 23 ms
58,668 KB
testcase_20 AC 2 ms
5,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

long long N, M, X, Y, Z;
long long A[1 << 18];
long long dp[55][55][2505];

int main() {
	cin >> N >> M >> X >> Y >> Z;
	for (int i = 0; i < N; i++) cin >> A[i];
	sort(A, A + N);
	reverse(A, A + N);
	if (A[M] >= X) {
		cout << "Handicapped" << endl;
		return 0;
	}

	dp[0][0][0] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= N; j++) {
			for (int k = 0; k <= 2500; k++) {
				if (dp[i][j][k] == 0) continue;
				if (A[i] > Y) {
					dp[i + 1][j + 1][k + A[i]] += dp[i][j][k];
				}
				if (A[i] < X) {
					dp[i + 1][j][k] += dp[i][j][k];
				}
			}
		}
	}

	long long Answer = 0;
	for (int i = 1; i <= M; i++) {
		Answer += dp[N][i][i * Z];
	}
	cout << Answer << endl;
	return 0;
}
0