結果
問題 |
No.269 見栄っ張りの募金活動
|
ユーザー |
|
提出日時 | 2023-09-13 17:09:23 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 20 ms / 5,000 ms |
コード長 | 731 bytes |
コンパイル時間 | 661 ms |
コンパイル使用メモリ | 71,648 KB |
実行使用メモリ | 19,584 KB |
最終ジャッジ日時 | 2024-07-01 01:52:04 |
合計ジャッジ時間 | 1,677 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
// No.269 見栄っ張りの募金活動 #include <iostream> #include <vector> using namespace std; typedef long long ll; const ll mod = 1'000'000'007; int main() { int N, S, K; cin >> N >> S >> K; if (S - N * (N - 1) / 2 * K < 0) { cout << 0 << endl; return 0; } vector<vector<ll>> dp(N + 1, vector<ll>(S - N * (N - 1) / 2 * K + 1, 0)); dp[0][0] = 1; for (int i = 1; i <= N; ++i) { for (int j = 0; j <= S - N * (N - 1) / 2 * K; ++j) { if (j - i >= 0) { dp[i][j] = (dp[i][j - i] + dp[i - 1][j]) % mod; } else { dp[i][j] = dp[i - 1][j]; } } } cout << dp[N][S - N * (N - 1) / 2 * K] << endl; }