結果

問題 No.269 見栄っ張りの募金活動
ユーザー Haruki KurokawaHaruki Kurokawa
提出日時 2023-02-13 12:16:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,110 bytes
コンパイル時間 1,588 ms
コンパイル使用メモリ 165,300 KB
実行使用メモリ 18,608 KB
最終ジャッジ日時 2023-09-23 10:20:49
合計ジャッジ時間 3,436 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 4 ms
6,456 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 4 ms
15,732 KB
testcase_07 RE -
testcase_08 WA -
testcase_09 AC 2 ms
4,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,376 KB
testcase_13 WA -
testcase_14 AC 2 ms
4,376 KB
testcase_15 WA -
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 4 ms
6,088 KB
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[100][20000];
int N, S, K;
ll M = pow(10,9) + 7;
int main(){
    cin >> N >> S >> K;
    if(K*N*(N-1)/2 > S){
        cout << 0 << endl;
        return 0;
    }
    int i, j;
    dp[0][0] = 1;
    if(K == 0){
        for(i=1; i<=N; i++){
            for(j=0; j<=S; j++){
                if(j-i < 0){
                    dp[i][j] = dp[i-1][j] % M;
                }
                else{
                    dp[i][j] = (dp[i][j-i] + dp[i-1][j]) % M;
                }
            }
        }
    }
    else if(K >= 1){
        for(i=1; i<=N; i++){
            int min_money = K*i*(i-1)/2;
            for(j=min_money; j<=S; j++){
                if(j < i-1){
                    dp[i][j] = 0;
                }
                else if(i-1 <= j && j < i){
                    dp[i][j] = dp[i-1][j-(i-1)] % M;
                }
                else{
                    dp[i][j] = (dp[i][j-i] + dp[i-1][j-(i-1)]) % M;
                }
            }
        }
    }
    cout << dp[N][S] << endl;
}
0