結果
問題 | No.1238 選抜クラス |
ユーザー |
![]() |
提出日時 | 2020-09-07 23:04:26 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 132 ms / 2,000 ms |
コード長 | 904 bytes |
コンパイル時間 | 1,622 ms |
コンパイル使用メモリ | 168,912 KB |
実行使用メモリ | 19,200 KB |
最終ジャッジ日時 | 2024-11-29 11:30:52 |
合計ジャッジ時間 | 4,313 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0; i<(int)(n); i++) using namespace std; using LL = long long; const LL mod = 1e9 + 7; const int Max_N = 100; const int Max_K = 100; const int Max_A = 100; LL dp[2][Max_N + 5][Max_N * Max_A + 5]; int main(){ int N, K; cin >> N >> K; assert(1 <= N and N <= Max_N); assert(0 <= K and K <= Max_K); vector<int> A(N); rep(i,N){ int a; cin >> a; assert(0 <= a and a <= Max_A); A[i] = a; } dp[0][0][0] = 1; for(int i = 1; i <= N; i++){ for(int j = 0; j <= i; j++){ for(int S = 0; S <= i * Max_A; S++){ dp[i%2][j][S] = dp[(i+1)%2][j][S]; if(S >= A[i-1] and j > 0){ dp[i%2][j][S] += dp[(i+1)%2][j-1][S-A[i-1]]; } dp[i%2][j][S] %= mod; } } } LL ans = 0; for(int j = 1; j <= N; j++){ for(int S = j * K; S <= j * Max_A; S++){ ans += dp[N%2][j][S]; ans %= mod; } } cout << ans << endl; return 0; }