結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー |
![]() |
提出日時 | 2015-09-16 09:22:02 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 22 ms / 5,000 ms |
コード長 | 657 bytes |
コンパイル時間 | 674 ms |
コンパイル使用メモリ | 83,920 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-07-16 01:49:38 |
合計ジャッジ時間 | 1,429 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <algorithm> #include <climits> #include <deque> #include <iostream> #include <queue> #include <random> #include <string> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> i_i; struct edge { int i, v, z; }; int MOD = 1000000007; int main() { int N, S, K; cin >> N >> S >> K; vector<vector<int> > dp(N + 1, vector<int>(S + 1)); dp[N][0] = 1; for (int i = N; i > 0; i--) for (int j = 0; j <= S; j++) { if (j + i <= S) dp[i][j + i] = (dp[i][j + i] + dp[i][j]) % MOD; if (j + (i - 1) * K <= S) dp[i - 1][j + (i - 1) * K] = (dp[i - 1][j + (i - 1) * K] + dp[i][j]) % MOD; } cout << dp[0][S] << endl; }