結果
| 問題 |
No.1457 ツブ消ししとるなHard
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2021-03-31 22:08:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 16 ms / 2,000 ms |
| コード長 | 682 bytes |
| コンパイル時間 | 1,814 ms |
| コンパイル使用メモリ | 192,704 KB |
| 最終ジャッジ日時 | 2025-01-20 03:37:25 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 17 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | scanf("%d%d%d%d%d",&N,&M,&X,&Y,&Z);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:13:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | rep(i,N) scanf("%d",&A[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#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;
}
Nachia