結果

問題 No.269 見栄っ張りの募金活動
ユーザー KumachanKumachan
提出日時 2019-06-20 16:20:30
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 2,094 bytes
コンパイル時間 483 ms
コンパイル使用メモリ 62,596 KB
実行使用メモリ 18,716 KB
最終ジャッジ日時 2023-08-22 18:17:10
合計ジャッジ時間 1,611 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>

using namespace std;

// typedef
typedef long long ll;

// container util
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(c) int((c).size())
#define EACH(i,c) for(auto (i)=(c).begin(); (i)!=(c).end(); ++(i))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))

// repetition
#define FOR(i,m,n) for(ll (i) = ((ll) m); (i) < ((ll) n); ++(i))
#define RFOR(i,m,n) for(ll (i) = ((ll) (m)-1); (i) >= ((ll) n); --(i))
#define REP(i,n) FOR(i,0,n)

// i/o
#define TFOUT(b,t,f) cout << ((b)? (t) : (f)) << endl

// constant
const double    EPS     = 1e-10;
const int       INFTY   = (1<<21);
const ll        MOD     = (ll) 1e9+7;

// clear memory
#define CLR(a) memset((a),0,sizeof(a))

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << " " << __FILE__ << endl

int main() {
    int n, s, k; cin >> n >> s >> k;
    int m = s - k*(n-1)*n/2;
    if(m < 0) {
        cout << 0 << endl;
        return 0;
    }
    vector<ll> dp((m+1)*n, 0);
    REP(i, n) {
        REP(j, m+1) {
            if (i == 0) {
                dp[i*(m+1)+j] = 1;
                continue;
            }
            ll val = dp[(i-1)*(m+1)+j];
            if (j-i-1 >= 0) val += dp[i*(m+1)+j-i-1];
            dp[i*(m+1)+j] = val % MOD;
        }
    }
    cout << *(dp.end() - 1) << endl;
    return 0;
}
/*
見栄っ張りの募金活動
https://yukicoder.me/problems/no/269

数字の間の差が一定以上であれという制約がある分割の問題は,
各数字(ai)が取りうる最小値(mi)の和Mを一致させたい和Sからあらかじめ引いておいて,
その上でSの分割を求めれば良い. ある分割{bi}が得られたらそれをソートして
ai = mi + bi
とすれば良い. すなわち(順序をもたない)分割{bi}が順序付きの列(ai)に一対一で対応する.
*/
0