結果

問題 No.269 見栄っ張りの募金活動
ユーザー YazatenYazaten
提出日時 2018-07-04 15:25:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4,667 ms / 5,000 ms
コード長 764 bytes
コンパイル時間 1,854 ms
コンパイル使用メモリ 164,160 KB
実行使用メモリ 19,396 KB
最終ジャッジ日時 2023-09-23 01:32:27
合計ジャッジ時間 19,319 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
19,092 KB
testcase_01 AC 7 ms
19,120 KB
testcase_02 AC 7 ms
19,292 KB
testcase_03 AC 18 ms
19,096 KB
testcase_04 AC 3,302 ms
19,144 KB
testcase_05 AC 8 ms
19,144 KB
testcase_06 AC 7 ms
19,392 KB
testcase_07 AC 4,667 ms
19,264 KB
testcase_08 AC 8 ms
19,268 KB
testcase_09 AC 7 ms
19,252 KB
testcase_10 AC 7 ms
19,360 KB
testcase_11 AC 1,596 ms
19,064 KB
testcase_12 AC 7 ms
19,072 KB
testcase_13 AC 680 ms
19,328 KB
testcase_14 AC 1,362 ms
19,160 KB
testcase_15 AC 968 ms
19,096 KB
testcase_16 AC 7 ms
19,084 KB
testcase_17 AC 7 ms
19,132 KB
testcase_18 AC 994 ms
19,396 KB
testcase_19 AC 325 ms
19,180 KB
testcase_20 AC 249 ms
19,192 KB
testcase_21 AC 1,149 ms
19,140 KB
testcase_22 AC 239 ms
19,176 KB
testcase_23 AC 12 ms
19,168 KB
testcase_24 AC 674 ms
19,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back

const ll MOD = 1e9+7;
signed main(){
    int n,s,k;
    cin>>n>>s>>k;
    
    s -= n*(n-1)/2*k;
    
    static int dp[101][20001];
    rep(i,101)rep(j,20001)dp[i][j] = 0;
    dp[0][0] = 1;
    
    for(int i=1;i<=n;i++){
        for(int j=0;j<=s;j++){
            int pay = 0;
            int remain = n-i+1;
            while(1){
                if(j-pay>=0)(dp[i][j] += dp[i-1][j-pay])%=MOD;
                else break;
                pay += remain;
                int remain = n-i+1;
            }
        }
    }
    cout<<dp[n][s]<<endl;
}
0