結果

問題 No.269 見栄っ張りの募金活動
ユーザー min9813min9813
提出日時 2020-03-21 18:35:29
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 19 ms / 5,000 ms
コード長 1,067 bytes
コンパイル時間 765 ms
コンパイル使用メモリ 84,760 KB
実行使用メモリ 11,744 KB
最終ジャッジ日時 2023-08-24 21:32:04
合計ジャッジ時間 2,364 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
11,608 KB
testcase_01 AC 8 ms
11,736 KB
testcase_02 AC 8 ms
11,688 KB
testcase_03 AC 9 ms
11,512 KB
testcase_04 AC 12 ms
11,556 KB
testcase_05 AC 8 ms
11,500 KB
testcase_06 AC 8 ms
11,472 KB
testcase_07 AC 19 ms
11,608 KB
testcase_08 AC 8 ms
11,604 KB
testcase_09 AC 13 ms
11,704 KB
testcase_10 AC 9 ms
11,508 KB
testcase_11 AC 9 ms
11,576 KB
testcase_12 AC 12 ms
11,464 KB
testcase_13 AC 9 ms
11,504 KB
testcase_14 AC 8 ms
11,520 KB
testcase_15 AC 9 ms
11,628 KB
testcase_16 AC 11 ms
11,576 KB
testcase_17 AC 9 ms
11,464 KB
testcase_18 AC 14 ms
11,744 KB
testcase_19 AC 10 ms
11,508 KB
testcase_20 AC 8 ms
11,612 KB
testcase_21 AC 9 ms
11,672 KB
testcase_22 AC 9 ms
11,736 KB
testcase_23 AC 8 ms
11,656 KB
testcase_24 AC 9 ms
11,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
using namespace std;
typedef long long llong;
static const int max_n = 110;
static const int max_s = 20010;
static const int mod = 1000000007;
// static const int max_v = 10000000;
// vector<int> num_array(max_n);
vector<vector<int>> dp(max_n, vector<int>(max_s, 0));

int main(){
    int N, S, K;
    scanf("%d %d %d", &N, &S, &K);

    dp[0][0] = 1;
    // dp[1][0] = 1;/

    for(int i=0;i<N;i++){
        for(int j=0;j<=S;j++){
            // printf("i=%d, j=%d, N-j+1=%d\n", i, j, N-i+1);
            if(j>=(N-i)){
                dp[i][j] = (dp[i][j] + dp[i][j-(N-i)]) % mod;
                // printf("yes, dp[%d][%d]=%d\n", i, j, dp[i][j]);

            }

            if(j>=K*(N-i) && i >= 1){
                dp[i][j] = (dp[i][j] + dp[i-1][j-K*(N-i)]) % mod;
                // printf("no, dp[%d][%d]=%d\n", i, j, dp[i][j]);

            }
        }
    }

    printf("%d\n", dp[N-1][S]);

}
0