結果

問題 No.269 見栄っ張りの募金活動
ユーザー hkrhkr
提出日時 2018-04-25 23:05:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 18 ms / 5,000 ms
コード長 539 bytes
コンパイル時間 1,182 ms
コンパイル使用メモリ 144,920 KB
実行使用メモリ 19,120 KB
最終ジャッジ日時 2023-09-23 01:28:41
合計ジャッジ時間 2,301 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 3 ms
4,476 KB
testcase_04 AC 9 ms
9,432 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 18 ms
19,120 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 10 ms
10,340 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 3 ms
5,112 KB
testcase_12 AC 7 ms
8,744 KB
testcase_13 AC 4 ms
5,356 KB
testcase_14 AC 3 ms
4,384 KB
testcase_15 AC 4 ms
5,188 KB
testcase_16 AC 8 ms
8,352 KB
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 12 ms
13,176 KB
testcase_19 AC 4 ms
5,844 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 3 ms
4,440 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, S, K;
  cin >> N >> S >> K;

  ll dp[S+1][N+1];
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  ll mod = 1e9+7;

  for(int i=0;i<=S;i++) {
    for(int j=1;j<=N;j++) {
      dp[i][j] = dp[i][j-1];
      if(i-j >= 0)
        dp[i][j] += dp[i-j][j];
      dp[i][j] %= mod;
    }
  }

  ll x = S;
  for(int i=0;i<N;i++)
    x -= i*K;
  if(x < 0)
    cout << 0 << endl;
  else
    cout << dp[x][N] << endl;
}
0