結果

問題 No.1457 ツブ消ししとるなHard
ユーザー simansiman
提出日時 2022-02-24 12:04:18
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,121 bytes
コンパイル時間 3,922 ms
コンパイル使用メモリ 107,608 KB
実行使用メモリ 49,336 KB
最終ジャッジ日時 2023-09-15 06:45:43
合計ジャッジ時間 6,443 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 4 ms
9,456 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 WA -
testcase_10 AC 3 ms
5,784 KB
testcase_11 WA -
testcase_12 AC 6 ms
11,452 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 4 ms
8,556 KB
testcase_16 WA -
testcase_17 AC 2 ms
4,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  int N, M, X, Y, Z;
  cin >> N >> M >> X >> Y >> Z;

  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }

  ll dp[N + 1][M + 1][M * Z + 1];
  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;
  int rc = 0;

  for (int i = 0; i < N; ++i) {
    int a = A[i];
    if (a < X) {
      memcpy(dp[i + 1], dp[i], sizeof(dp[i]));
      ++rc;
    }
    if (a <= Y) {
      memcpy(dp[i + 1], dp[i], sizeof(dp[i]));
      continue;
    }

    for (int m = M - 1; m >= 0; --m) {
      for (int j = M * Z - a; j >= 0; --j) {
        dp[i + 1][m + 1][j + a] += dp[i][m][j];
      }
    }
  }

  ll ans = 0;

  for (int m = 1; m <= M; ++m) {
    fprintf(stderr, "m: %d, cnt: %lld\n", m, dp[N][m][m * Z]);
    ans += dp[N][m][m * Z];
  }

  if (N - rc > M) {
    cout << "Handicapped" << endl;
  } else if (ans == 0) {
    cout << ans << endl;
  }

  return 0;
}
0