結果

問題 No.1457 ツブ消ししとるなHard
コンテスト
ユーザー 👑 Nachia
提出日時 2021-03-31 22:08:59
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 682 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,394 ms
コンパイル使用メモリ 210,400 KB
実行使用メモリ 25,472 KB
最終ジャッジ日時 2026-05-25 21:32:31
合計ジャッジ時間 3,244 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int N,M,X,Y,Z;
int A[50];
ll dp[51][51][2501]={};

int main(){
  scanf("%d%d%d%d%d",&N,&M,&X,&Y,&Z);
  rep(i,N) scanf("%d",&A[i]);
  dp[0][0][0]=1;
  rep(i,N) rep(k,i+1) rep(s,50*i+1){
    if(A[i]>Y) dp[i+1][k+1][s+A[i]] += dp[i][k][s];
    if(A[i]<X) dp[i+1][k][s] += dp[i][k][s];
  }
  bool Handicapped = true;
  for(int k=1; k<=M; k++) rep(s,2501) if(dp[N][k][s]!=0) Handicapped = false;
  if(Handicapped){ printf("Handicapped\n"); return 0; }
  ll ans=0;
  for(int k=1; k<=M; k++) ans+=dp[N][k][Z*k];
  printf("%lld\n",ans);
  return 0;
}
0