結果

問題 No.269 見栄っ張りの募金活動
ユーザー Kazuho MorikawaKazuho Morikawa
提出日時 2021-06-14 01:23:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4,721 ms / 5,000 ms
コード長 1,156 bytes
コンパイル時間 1,522 ms
コンパイル使用メモリ 168,648 KB
実行使用メモリ 19,476 KB
最終ジャッジ日時 2023-08-25 04:41:23
合計ジャッジ時間 19,455 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 14 ms
4,376 KB
testcase_04 AC 3,317 ms
9,068 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 4,721 ms
19,476 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1,589 ms
4,500 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 680 ms
5,168 KB
testcase_14 AC 1,357 ms
4,380 KB
testcase_15 AC 969 ms
4,876 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1,006 ms
8,708 KB
testcase_19 AC 323 ms
4,588 KB
testcase_20 AC 244 ms
4,380 KB
testcase_21 AC 1,150 ms
4,376 KB
testcase_22 AC 237 ms
4,376 KB
testcase_23 AC 6 ms
4,380 KB
testcase_24 AC 671 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back



int main()
{
    ll N, S, K;
    cin >> N >> S >> K;

    ll M = S - N * (N-1) * K / 2;
    ll ans;
    if(M < 0) ans = 0;
    else {
        mat dp(N+1, vec(M+1, 0));
        REP(i,0,N+1) dp[i][0] = 1;
        REP(i,1,N+1) {
            REP(j,1,M+1) {
                REP(k,0,j/(N-i+1)+1) {
                    dp[i][j] = (dp[i][j] + dp[i-1][j-(N-i+1)*k]) % MOD;
                }
            }
        }
        ans = dp[N][M];
    }
    PR(ans);

    return 0;
}

/*



*/
0