結果

問題 No.269 見栄っ張りの募金活動
ユーザー hiroahiroa
提出日時 2019-08-09 18:27:19
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 4,067 ms / 5,000 ms
コード長 685 bytes
コンパイル時間 2,054 ms
コンパイル使用メモリ 163,756 KB
実行使用メモリ 19,384 KB
最終ジャッジ日時 2023-09-26 13:19:10
合計ジャッジ時間 13,366 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
19,100 KB
testcase_01 AC 7 ms
19,108 KB
testcase_02 AC 8 ms
19,112 KB
testcase_03 AC 17 ms
19,384 KB
testcase_04 AC 2,636 ms
19,188 KB
testcase_05 AC 8 ms
19,112 KB
testcase_06 AC 8 ms
19,104 KB
testcase_07 AC 4,067 ms
19,172 KB
testcase_08 AC 7 ms
19,108 KB
testcase_09 AC 7 ms
19,104 KB
testcase_10 AC 7 ms
19,104 KB
testcase_11 AC 979 ms
19,260 KB
testcase_12 AC 7 ms
19,104 KB
testcase_13 AC 523 ms
19,168 KB
testcase_14 AC 7 ms
19,192 KB
testcase_15 AC 705 ms
19,244 KB
testcase_16 AC 7 ms
19,112 KB
testcase_17 AC 7 ms
19,188 KB
testcase_18 AC 843 ms
19,220 KB
testcase_19 AC 258 ms
19,248 KB
testcase_20 AC 119 ms
19,116 KB
testcase_21 AC 102 ms
19,196 KB
testcase_22 AC 184 ms
19,184 KB
testcase_23 AC 11 ms
19,104 KB
testcase_24 AC 315 ms
19,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int N,S,K;
ll dp[101][20010];

ll dfs(int n,int y){
    if(y<0) return 0;
    if(n==N-1) return 1;
    ll& ret=dp[n][y];
    if(ret>=0) return ret;
    ret=0;
    for(int i=0;i*(N-n)<=y;i++){
        ret+=dfs(n+1,y-i*(N-n));
    }
    ret%=MOD;
    return ret;
}

int main(void) {
    cin>>N>>S>>K;
    dp[0][0]=1;
    S-=N*(N-1)/2*K;
    memset(dp,-1,sizeof(dp));
    cout<<dfs(0,S)<<endl;
}
0