結果

問題 No.269 見栄っ張りの募金活動
コンテスト
ユーザー addx
提出日時 2026-02-03 18:51:00
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
結果
AC  
実行時間 7 ms / 5,000 ms
コード長 1,330 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 5,105 ms
コンパイル使用メモリ 214,504 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-02-03 18:51:07
合計ジャッジ時間 6,222 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int mod = 1000000007;
#include <chrono>
mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1};
int dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};
template<class T>
bool chmin(T& a, const T& b){
    if (b < a){
        a = b;
        return true;
    }
    else { 
        return false;
    }
}
template<class T> 
bool chmax(T& a, const T& b){
    if (a < b){
        a = b;
        return true;
    }
    else {
        return false;
    }
}
void solve(){
    int n, s, k;
    cin >> n >> s >> k;
    s -= k * n * (n - 1) / 2;
    if (s < 0){
        cout << 0 << '\n';
        return;
    }
    vector<ll> dp(s + 1);
    dp[0] = 1;
    for (int i = 1; i <= n; i++){
        vector<ll> dp2(s + 1);
        for (int j = 0; j <= s; j++){
            if (j >= i){
                dp2[j] += dp[j] + dp2[j - i];
            }
            else {
                dp2[j] += dp[j];                
            }
            dp2[j] %= mod;
        }
        swap(dp, dp2);
    }
    cout << dp[s] << '\n';
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    while(t--){
        cout << fixed << setprecision(15);        
        solve();
    }
}
0