結果

問題 No.269 見栄っ張りの募金活動
ユーザー 4batakosan4batakosan
提出日時 2019-06-22 11:55:25
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 23 ms / 5,000 ms
コード長 870 bytes
コンパイル時間 826 ms
コンパイル使用メモリ 99,104 KB
実行使用メモリ 19,444 KB
最終ジャッジ日時 2023-08-27 02:42:57
合計ジャッジ時間 2,375 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 10 ms
9,448 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 23 ms
19,444 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 11 ms
10,156 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 4 ms
4,772 KB
testcase_12 AC 9 ms
8,568 KB
testcase_13 AC 4 ms
5,156 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 4 ms
5,072 KB
testcase_16 AC 8 ms
8,092 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 15 ms
13,220 KB
testcase_19 AC 5 ms
5,596 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

#define MOD (int64_t)(1e+9 + 7)

using namespace std;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, s, k; cin >> n >> s >> k;
    
    vector<vector<int64_t>> dp(n + 1, vector<int64_t>(s + 1, 0));
    
    dp[0][0] = 1;
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= s; j++) {
            if (j >= k * i) {
                dp[i + 1][j] += dp[i][j - k * i];
                dp[i + 1][j] %= MOD;
            }
            if (j >= i + 1) {
                dp[i + 1][j] += dp[i + 1][j - i - 1];
                dp[i + 1][j] %= MOD;
            }
        }
    }
    
    cout << dp[n][s] % MOD << endl;
    
    return 0;
}
0