結果

問題 No.269 見栄っ張りの募金活動
ユーザー りりんばるりりんばる
提出日時 2023-12-01 10:39:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 30 ms / 5,000 ms
コード長 1,077 bytes
コンパイル時間 2,425 ms
コンパイル使用メモリ 211,116 KB
実行使用メモリ 11,904 KB
最終ジャッジ日時 2023-12-01 10:39:36
合計ジャッジ時間 3,939 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,676 KB
testcase_01 AC 3 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 3 ms
6,676 KB
testcase_04 AC 12 ms
6,912 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 30 ms
11,904 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 5 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 5 ms
6,676 KB
testcase_14 AC 4 ms
6,676 KB
testcase_15 AC 6 ms
6,676 KB
testcase_16 AC 3 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 11 ms
6,676 KB
testcase_19 AC 5 ms
6,676 KB
testcase_20 AC 3 ms
6,676 KB
testcase_21 AC 4 ms
6,676 KB
testcase_22 AC 5 ms
6,676 KB
testcase_23 AC 2 ms
6,676 KB
testcase_24 AC 3 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, p, n) for (ll i = p; i < (ll)(n); i++)
#define rep2(i, p, n) for(ll i = p; i >= (ll)(n); i-- )
using namespace std;
using ll = long long;
double pi=3.141592653589793;
const long long inf=2*1e9;
const long long linf=8*1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
//atcoder
#include <atcoder/modint>
#include <atcoder/dsu>
using namespace atcoder;
using mint1 = modint1000000007;
using mint2 = modint998244353;

int main() {
    ll N, S, K;
    cin >> N >> S >> K;
    S-=((N-1)*N/2)*K;
    if (S<0) {
    	cout << 0 << endl;
    	return 0;
    }
    vector<vector<mint1>> dp(S+1, vector<mint1>(N+1));
    rep(i, 0, N+1) {
        dp.at(0).at(i)=1;
    }
    rep(i, 0, S) {
        rep(j, 0, N+1) {
            mint1 A=0;
            if (j>0) {
                A=dp.at(i+1).at(j-1);
            }
            mint1 B=0;
            if ((i+1)>=j) {
                B=dp.at(i+1-j).at(j);
            }
            dp.at(i+1).at(j)=A+B;
        }
    }
    cout << dp.at(S).at(N).val();
}
0