結果

問題 No.269 見栄っ張りの募金活動
ユーザー leaf_bleaf_b
提出日時 2019-07-22 19:42:49
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 5,000 ms
コード長 999 bytes
コンパイル時間 1,389 ms
コンパイル使用メモリ 165,152 KB
実行使用メモリ 19,136 KB
最終ジャッジ日時 2023-09-05 23:20:53
合計ジャッジ時間 2,448 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 3 ms
11,700 KB
testcase_04 AC 5 ms
9,204 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 4 ms
15,796 KB
testcase_07 AC 10 ms
19,136 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 3 ms
4,724 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 3 ms
8,296 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 3 ms
6,496 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 5 ms
14,612 KB
testcase_19 AC 3 ms
8,064 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
6,000 KB
testcase_23 AC 3 ms
5,620 KB
testcase_24 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e18;
const int MOD = 1e9 + 7;

int dp[101][20001];

signed main(){
    int N, S, K; cin >> N >> S >> K;
    FOR( i, 1, N ){
        S -= i * K;
    }

    dp[0][0] = 1;
    FOR( i, 1, N + 1 ){
        REP( j, S + 1 ){
            if( j - i >= 0 ){
                dp[i][j] = ( dp[i - 1][j] + dp[i][j - i] ) % MOD;
            }else{
                dp[i][j] = dp[i - 1][j];
            }
        }
    }

    cout << dp[N][S] << endl;
}
0