結果
| 問題 | No.269 見栄っ張りの募金活動 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-01-01 20:36:34 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 47 ms / 5,000 ms |
| コード長 | 5,471 bytes |
| 記録 | |
| コンパイル時間 | 3,030 ms |
| コンパイル使用メモリ | 282,060 KB |
| 実行使用メモリ | 19,456 KB |
| 最終ジャッジ日時 | 2026-01-01 20:36:39 |
| 合計ジャッジ時間 | 3,889 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using bl = bool;
// using mint = modint;
// mint::set_mod(m);
template <class T>
using pq = priority_queue<T, vector<T>>;
template <class T>
using pq_g = priority_queue<T, vector<T>, greater<T>>;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
template <class T>
istream& operator>>(istream& i, vector<T>& v) {
rep(j, size(v)) i >> v[j];
return i;
}
const int inf = 1073741823;
const ll infl = 1LL << 60;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define drep(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define nfor(i, s, n) for (ll i = s; i < n; i++)
#define dfor(i, s, n) for (ll i = (s) - 1; i >= n; i--)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YN \
{ \
cout << "Yes" << endl; \
} \
else { \
cout << "No" << endl; \
} // if(a==b)YN;
#define vc_unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define vc_rotate(v) rotate(v.begin(), v.begin() + 1, v.end());
#define pop_cnt(s) ll(popcount(uint64_t(s)))
#define next_p(v) next_permutation(v.begin(), v.end())
vector<int> dx = {1, 0, -1, 0}; // vl dx={1,1,0,-1,-1,-1,0,1};
vector<int> dy = {0, 1, 0, -1}; // vl dy={0,1,1,1,0,-1,-1,-1};
bool out_grid(ll i, ll j, ll h, ll w = -1) {
if (w == -1) {
w = h;
}
return (!(0 <= i && i < h && 0 <= j && j < w));
}
#define vvl_rotate(v) \
{ \
ll n = size(v); \
vvl nx(n, vl(n)); \
rep(i, n) rep(j, n) nx[j][n - i - 1] = v[i][j]; \
swap(nx, v); \
} // 時計回りに90°回転
// #define vvl_rotate(v) {ll n = size(v);vvl
// nx(n,vl(n));rep(i,n)rep(j,n)nx[n-j-1][i]=v[i][j];swap(nx,v);}//反時計周りに90°回転
#define vs_rotate(v) \
{ \
ll n = size(v); \
vs nx(n, string(n, '.')); \
rep(i, n) rep(j, n) nx[j][n - i - 1] = v[i][j]; \
swap(nx, v); \
} // 文字列版 時計回りに90°回転
// #define vs_rotate(v) {ll n = size(v);vs
// nx(n,string(n,'.'));rep(i,n)rep(j,n)nx[n-j-1][i]=v[i][j];swap(nx,v);}//文字列版 反時計周りに90°回転
#define vvl_transpos(v) \
{ \
ll n = size(v); \
vvl nx(n, vl(n)); \
rep(i, n) rep(j, n) nx[j][i] = v[i][j]; \
swap(nx, v); \
}
#define vs_transpos(v) \
{ \
ll n = size(v); \
vs nx(n, string(n, '.')); \
rep(i, n) rep(j, n) nx[j][i] = v[i][j]; \
swap(nx, v); \
}
#define euclid(x, y) ((x) * (x) + (y) * (y)) // ユークリッド距離 2乗のまま
#define manhattan(x1, x2, y1, y2) \
(abs(x1 - x2) + abs(y1 - y2)) // マンハッタン距離 = |x1-x2|+|y1-y2|
ll nc2(ll x) { return x * (x - 1) / 2; }
ll nc3(ll x) { return x * (x - 1) * (x - 2) / 6; }
//----------------------------------------------
//-----------6.デバックや出力系------------------
void print(ld x) { printf("%.20Lf\n", x); }
#define print_vec(v) \
{ \
ll n = size(v); \
rep(i, n) cout << v[i] << " "; \
cout << endl; \
} // 一次元配列を出力する(改行なし)
#define vc_cout(v) \
{ \
ll n = size(v); \
rep(i, n) cout << v[i] << endl; \
} // 一次元配列を出力する(改行あり)
#define vv_cout(v) \
{ \
ll n = size(v); \
rep(i, n) { \
rep(j, size(v[i])) { cout << v[i][j] << ' '; } \
cout << endl; \
} \
} // 二次元配列を出力する
//----------------------------------------------
ll mod = 1e9 + 7;
int main() {
cout << fixed << setprecision(10);
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n, s, k;
cin >> n >> s >> k;
s -= k * n * (n - 1) / 2;
if (s < 0) {
cout << 0 << endl;
return 0;
}
vector dp(s + 1, vector<ll>(n + 1));
dp[0][1] = 1;
rep(i, s + 1) {
rep(j, n + 1) {
if (i - j >= 0) {
dp[i][j] += dp[i - j][j];
}
if (j > 0) dp[i][j] += dp[i][j - 1];
dp[i][j] %= mod;
}
}
cout << dp[s][n] << endl;
return 0;
}