結果
問題 | No.1457 ツブ消ししとるなHard |
ユーザー |
|
提出日時 | 2024-09-22 15:14:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 983 bytes |
コンパイル時間 | 2,793 ms |
コンパイル使用メモリ | 201,672 KB |
最終ジャッジ日時 | 2025-02-24 11:31:32 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 14 WA * 3 |
ソースコード
#include<bits/stdc++.h>using namespace std;using ll=long long;int main(){cin.tie(nullptr);ios::sync_with_stdio(false);ll N,M,X,Y,Z;cin>>N>>M>>X>>Y>>Z;ll BG=0,BGS=0;vector<ll> A;for(int i=0;i<N;i++){ll a;cin>>a;if(a>=X){BG++;BGS+=a;}else if(a>=Y)A.push_back(a);}if(BG>M){cout<<"Handicapped"<<endl;return 0;}N=A.size();vector<vector<ll>> DP(N+1,vector<ll>(N*50+1,0));DP[0][0]=1;for(int i=0;i<N;i++){auto NDP=DP;for(int j=0;j<N;j++){for(int s=0;s+A[i]<=N*50;s++){NDP[j+1][s+A[i]]+=DP[j][s];}}swap(DP,NDP);}ll an=0;for(int i=0;i<=N;i++){for(ll s=0;s<=N*50;s++){ll n=i+BG;if(n>M||n==0)continue;ll sm=s+BGS;if(n*Z==sm)an+=DP[i][s];}}cout<<an<<endl;}