結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー | kyuridenamida |
提出日時 | 2015-08-21 23:33:26 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 1,061 ms / 5,000 ms |
コード長 | 881 bytes |
コンパイル時間 | 1,141 ms |
コンパイル使用メモリ | 145,248 KB |
実行使用メモリ | 11,500 KB |
最終ジャッジ日時 | 2023-09-23 01:05:58 |
合計ジャッジ時間 | 5,354 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 5 ms
6,020 KB |
testcase_04 | AC | 742 ms
7,640 KB |
testcase_05 | AC | 2 ms
4,376 KB |
testcase_06 | AC | 3 ms
5,776 KB |
testcase_07 | AC | 1,061 ms
11,500 KB |
testcase_08 | AC | 2 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,380 KB |
testcase_10 | AC | 1 ms
4,380 KB |
testcase_11 | AC | 315 ms
4,380 KB |
testcase_12 | AC | 1 ms
4,380 KB |
testcase_13 | AC | 137 ms
6,524 KB |
testcase_14 | AC | 92 ms
4,376 KB |
testcase_15 | AC | 200 ms
4,376 KB |
testcase_16 | AC | 1 ms
4,376 KB |
testcase_17 | AC | 1 ms
4,376 KB |
testcase_18 | AC | 207 ms
7,536 KB |
testcase_19 | AC | 66 ms
6,088 KB |
testcase_20 | AC | 44 ms
4,376 KB |
testcase_21 | AC | 147 ms
4,376 KB |
testcase_22 | AC | 48 ms
4,380 KB |
testcase_23 | AC | 3 ms
4,380 KB |
testcase_24 | AC | 118 ms
4,380 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; int sum[20210] = {}; int dp[110][20110]; int N,S,K; vector<int> v; int dfs(int x,int s){ if( s < 0 ) return 0; if( dp[x][s] != -1 ) return dp[x][s]; if( x == 0 ){ return s == 0; } int ans = 0; for(int i = 0 ; ; i++){ int c = i * x; if( c > s ) break; ans += dfs(x-1,s-c); ans %= 1000000007; } return dp[x][s] = ans; } int main(){ cin >> N >> S >> K; S -= K*N*(N-1)/2; if( S < 0 ) cout << 0 << endl; else{ dp[N][S] = 1; for(register int x = N ; x >= 1 ; x--){ for(register int s = 0 ; s <= S ; s++){ if( dp[x][s] == 0 ) continue; register int c = 0; register int C = dp[x][s]; for(int k = 0 ; c <= s ; k++){ if( c > s ) break; dp[x-1][s-c] += C; if( dp[x-1][s-c] >= 1000000007 ) dp[x-1][s-c] -= 1000000007; c += x; } } } cout << dp[0][0] << endl; } }