結果
問題 |
No.1457 ツブ消ししとるなHard
|
ユーザー |
|
提出日時 | 2022-10-04 02:10:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 31 ms / 2,000 ms |
コード長 | 1,180 bytes |
コンパイル時間 | 2,156 ms |
コンパイル使用メモリ | 201,856 KB |
最終ジャッジ日時 | 2025-02-07 21:09:39 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N,M,X,Y,Z; cin >> N >> M >> X >> Y >> Z; vector<int> A; int SUM = 0, CNT = 0; rep(i,N) { int a; cin >> a; if(X <= a) { SUM += a; CNT++; } else if(a <= Y) { continue; } else { A.push_back(a); } } N = int(A.size()); if(CNT > M) { cout << "Handicapped" << endl; return 0; } int S = 50 * 50; vector<vector<ll>> dp(M + 1, vector<ll>(S + 1, 0)); dp[CNT][SUM] = 1; rep(i,N) { auto nt = dp; for(int m = 0; m <= M; m++) { for(int s = 0; s <= S; s++) { if(m + 1 <= M && s + A[i] <= S) nt[m + 1][s + A[i]] += dp[m][s]; } } swap(dp, nt); } ll ans = 0; for(int m = 1; m <= M; m++) { for(int s = 0; s <= S; s++) { if(s % m == 0 && s / m == Z) { ans += dp[m][s]; } } } cout << ans << endl; }