結果

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

ソースコード

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 = 0; i < n; i++){
        vector<ll> dp2(s + 1);
        for (int j = 0; j <= s; j++){
            for (int l = 0; l <= s; l++){
                ll x = 1LL * j * (n - i);                
                if (l < x){
                    continue;
                }
                dp2[l] += dp[l - x];
                dp2[l] %= 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