結果

問題 No.269 見栄っ張りの募金活動
ユーザー tomoe-htomoe-h
提出日時 2020-04-14 11:31:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 5,000 ms
コード長 524 bytes
コンパイル時間 1,491 ms
コンパイル使用メモリ 168,104 KB
実行使用メモリ 11,088 KB
最終ジャッジ日時 2023-07-24 21:57:45
合計ジャッジ時間 2,893 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 8 ms
11,088 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 8 ms
10,960 KB
testcase_04 AC 10 ms
10,912 KB
testcase_05 AC 8 ms
10,984 KB
testcase_06 AC 8 ms
11,060 KB
testcase_07 AC 13 ms
10,896 KB
testcase_08 AC 8 ms
10,924 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 8 ms
10,988 KB
testcase_11 AC 9 ms
11,036 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 9 ms
10,916 KB
testcase_14 AC 8 ms
10,960 KB
testcase_15 AC 9 ms
10,900 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 10 ms
10,980 KB
testcase_19 AC 9 ms
10,916 KB
testcase_20 AC 8 ms
10,920 KB
testcase_21 AC 8 ms
11,080 KB
testcase_22 AC 8 ms
10,960 KB
testcase_23 AC 8 ms
10,924 KB
testcase_24 AC 8 ms
10,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define pb push_back
using namespace std;
typedef long long ll;

const int mod = 1e9+7;

int main(){
  int n,s,k;
  cin>>n>>s>>k;
  
  int res = s-k*(n-1)*n/2;
  if(res<0){
    cout << 0 << endl;
    return 0;
  }
  
  vector<vector<int>> dp(102,vector<int>(20002));
  dp[0][0] = 1; 
  
  rep(i,n) rep(j,res+1){
    if(i) dp[i][j] = dp[i-1][j];
    if(j-i-1>=0){
      dp[i][j] += dp[i][j-i-1];
      dp[i][j] %= mod;
    }
  }
  
  cout << dp[n-1][res];
}
0