結果

問題 No.269 見栄っ張りの募金活動
ユーザー YazatenYazaten
提出日時 2018-07-04 16:37:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,784 ms / 5,000 ms
コード長 807 bytes
コンパイル時間 1,473 ms
コンパイル使用メモリ 165,876 KB
実行使用メモリ 50,668 KB
最終ジャッジ日時 2023-09-23 01:32:47
合計ジャッジ時間 12,526 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
50,496 KB
testcase_01 AC 16 ms
50,356 KB
testcase_02 AC 16 ms
50,368 KB
testcase_03 AC 22 ms
50,668 KB
testcase_04 AC 1,977 ms
50,344 KB
testcase_05 AC 16 ms
50,368 KB
testcase_06 AC 16 ms
50,364 KB
testcase_07 AC 2,784 ms
50,448 KB
testcase_08 AC 16 ms
50,380 KB
testcase_09 AC 16 ms
50,372 KB
testcase_10 AC 16 ms
50,424 KB
testcase_11 AC 966 ms
50,424 KB
testcase_12 AC 15 ms
50,448 KB
testcase_13 AC 416 ms
50,368 KB
testcase_14 AC 821 ms
50,368 KB
testcase_15 AC 590 ms
50,368 KB
testcase_16 AC 15 ms
50,628 KB
testcase_17 AC 15 ms
50,344 KB
testcase_18 AC 599 ms
50,376 KB
testcase_19 AC 203 ms
50,500 KB
testcase_20 AC 160 ms
50,368 KB
testcase_21 AC 698 ms
50,388 KB
testcase_22 AC 152 ms
50,452 KB
testcase_23 AC 18 ms
50,444 KB
testcase_24 AC 416 ms
50,376 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[301][20001];
    rep(i,301)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];
                    if(dp[i][j]>MOD)dp[i][j]-=MOD;
                }
                else break;
                pay += remain;
            }
        }
    }
    cout<<dp[n][s]<<endl;
}
0