結果

問題 No.269 見栄っ張りの募金活動
ユーザー simansiman
提出日時 2020-10-22 17:52:57
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 783 bytes
コンパイル時間 3,416 ms
コンパイル使用メモリ 100,340 KB
実行使用メモリ 19,284 KB
最終ジャッジ日時 2023-09-28 14:44:20
合計ジャッジ時間 16,777 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
19,244 KB
testcase_01 AC 7 ms
19,236 KB
testcase_02 AC 6 ms
19,180 KB
testcase_03 AC 19 ms
19,184 KB
testcase_04 AC 3,307 ms
19,156 KB
testcase_05 AC 7 ms
19,164 KB
testcase_06 AC 6 ms
19,236 KB
testcase_07 TLE -
testcase_08 AC 7 ms
19,164 KB
testcase_09 AC 7 ms
19,208 KB
testcase_10 AC 7 ms
19,160 KB
testcase_11 AC 1,254 ms
19,240 KB
testcase_12 AC 7 ms
19,172 KB
testcase_13 AC 660 ms
19,220 KB
testcase_14 AC 7 ms
19,176 KB
testcase_15 AC 895 ms
19,248 KB
testcase_16 AC 7 ms
19,208 KB
testcase_17 AC 6 ms
19,160 KB
testcase_18 AC 1,065 ms
19,240 KB
testcase_19 AC 325 ms
19,244 KB
testcase_20 AC 151 ms
19,168 KB
testcase_21 AC 148 ms
19,216 KB
testcase_22 AC 230 ms
19,180 KB
testcase_23 AC 12 ms
19,284 KB
testcase_24 AC 479 ms
19,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
const int INF = INT_MAX;
int N, S, K;

const int MAX_N = 101;
const int MAX_S = 20010;
ll dp[MAX_N][MAX_S];

ll dfs(int n, int s) {
  if (s < 0) return 0;
  if (n == N - 1) return 1;
  if (dp[n][s] != -1) return dp[n][s];

  ll res = 0;

  for (int i = 0; i * (N - n) <= s; ++i) {
    res += dfs(n + 1, s - i * (N - n));
    res %= MOD;
  }

  return dp[n][s] = res;
}

int main() {
  cin >> N >> S >> K;
  S -= (N * (N - 1) / 2) * K;
  memset(dp, -1, sizeof(dp));

  cout << dfs(0, S) << endl;

  return 0;
}
0