結果

問題 No.269 見栄っ張りの募金活動
ユーザー utanutan
提出日時 2021-04-27 02:41:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 5,000 ms
コード長 938 bytes
コンパイル時間 1,711 ms
コンパイル使用メモリ 165,788 KB
実行使用メモリ 20,724 KB
最終ジャッジ日時 2023-09-19 06:18:27
合計ジャッジ時間 3,224 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 6 ms
20,600 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 7 ms
20,532 KB
testcase_04 AC 14 ms
20,544 KB
testcase_05 AC 7 ms
20,532 KB
testcase_06 AC 7 ms
20,508 KB
testcase_07 AC 28 ms
20,600 KB
testcase_08 AC 6 ms
20,548 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 6 ms
20,552 KB
testcase_11 AC 9 ms
20,612 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 9 ms
20,604 KB
testcase_14 AC 8 ms
20,528 KB
testcase_15 AC 9 ms
20,536 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 14 ms
20,540 KB
testcase_19 AC 9 ms
20,536 KB
testcase_20 AC 7 ms
20,540 KB
testcase_21 AC 7 ms
20,604 KB
testcase_22 AC 9 ms
20,512 KB
testcase_23 AC 6 ms
20,724 KB
testcase_24 AC 8 ms
20,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;


typedef long long ll;
ll MOD = 1000000007;

const ll INF = 1001001001001001001;
const int inf = 1001001001;
using P = pair<ll, ll>;

struct edge {
    int to, cost;
};

bool comp(P l, P r) {
    return ((l.first < r.first) || ((l.first == r.first) && (l.second > r.second)));
    
}

int main() {
    int N, S, K;cin>> N >> S >> K;
    if (S-N*(N -1)*K/2 < 0) {
        cout << 0 << endl;
        return 0;
    }
    ll dp[110][20011] = {0LL};
    for (int i = 0; i <= 20010; i++) {
        dp[1][i] = 1LL;

    }
    for (int i = 2; i <= N; i++) {
        for (int j = 0; j <= S-N*(N-1)*K/2; j++) {
            if (j >= i) {
                dp[i][j] = (dp[i][j-i]+dp[i-1][j])%MOD;
            } else {
                dp[i][j] = (dp[i-1][j])%MOD;
            }

        }
    }
    cout << dp[N][S-N*(N-1)*K/2]%MOD << endl;
    return 0;
}
    
    
        
        
        
    
    


0