結果
問題 |
No.269 見栄っ張りの募金活動
|
ユーザー |
![]() |
提出日時 | 2021-04-20 15:01:02 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 18 ms / 5,000 ms |
コード長 | 582 bytes |
コンパイル時間 | 552 ms |
コンパイル使用メモリ | 72,064 KB |
実行使用メモリ | 11,264 KB |
最終ジャッジ日時 | 2024-07-04 05:20:55 |
合計ジャッジ時間 | 1,346 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <iostream> #include <vector> using namespace std; int main(){ int N,S,K; cin >> N >> S >> K; int mod = 1e9 + 7; vector<vector<int> > dp(N+1,vector<int>(S+1,0)); // (1)人目までの金額が決定していて、合計金額が(2)となるような場合のかず。 dp[1][0]=1; for(int i=1;i<=N;i++){ for(int j=0;j<=S;j++){ if( j >= K*(N-i+1) ) dp[i][j] += dp[i-1][j-K*(N-i+1)]%mod; if( j >= (N-i+1) ) dp[i][j] += dp[i][j-(N-i+1)]%mod; dp[i][j] = dp[i][j]%mod; } } cout << dp[N][S] << endl; }