結果

問題 No.269 見栄っ張りの募金活動
ユーザー huka_hukahuka_huka
提出日時 2021-09-25 13:33:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 22 ms / 5,000 ms
コード長 884 bytes
コンパイル時間 4,563 ms
コンパイル使用メモリ 147,988 KB
実行使用メモリ 11,692 KB
最終ジャッジ日時 2023-09-18 23:00:38
合計ジャッジ時間 6,156 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 10 ms
6,732 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 22 ms
11,692 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 4 ms
4,528 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 5 ms
4,596 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 4 ms
4,584 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 9 ms
6,152 KB
testcase_19 AC 4 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# ifndef ONLINE_JUDGE
# define _GLIBCXX_DEBUG
# endif
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
# define rep(i, n) for(int i = 0; i < (int)(n); ++i)
# define all(v) v.begin(), v.end()

int main(){
  constexpr char endl = '\n';
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
  //input();
  int N, S, K;cin >> N >> S >> K;
  //solve();
  S -= (N-1)*N/2*K;
  if(S < 0){
    cout << 0 << endl;
    return 0;
  }
  int mod = 1e9+7;
  //dp[i][j]:=iのj分割の総和
  vvi dp(S+1, vi(N+1));
  dp[0][0] = 1;
  for(int i = 0; i <= S; ++i){
    for(int j = 1; j <= N; ++j){
      if(0 <= i-j)  dp[i][j] = dp[i-j][j]+dp[i][j-1];
      else  dp[i][j] = dp[i][j-1];
      dp[i][j] %= mod;
    }
  }
  //output();
  cout << dp[S][N] << endl;
}
0