結果
問題 | No.1861 Required Number |
ユーザー |
|
提出日時 | 2022-03-04 21:39:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,174 bytes |
コンパイル時間 | 1,625 ms |
コンパイル使用メモリ | 172,988 KB |
実行使用メモリ | 82,048 KB |
最終ジャッジ日時 | 2024-07-18 22:32:22 |
合計ジャッジ時間 | 8,752 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 3 WA * 39 MLE * 4 |
ソースコード
#include <bits/stdc++.h> #define int long long #define rep(i,a,b) for(int i = a; i < b; i++) #define rerep(i,j,a,b) rep(i,a,b-1) rep(j,i+1,b) #define fore(i,a) for(auto &i : a) #define all(x) (x).begin(),(x).end() #define fix(i) fixed << setprecision(i) #define next_per(s) next_permutation(all(s)) using namespace std; template<class T>bool chmax(T& a, const T& b) { if(a < b) { a = b; return 1; } return 0; } template<class T>bool chmin(T& a, const T& b) { if(b < a) { a = b; return 1; } return 0; } using pii = pair<int, int>; using pque = priority_queue<int>; void main_(); signed main() { main_(); return 0; } /*------------------------------------------------------------------------------*/ const int INF = LLONG_MAX/2; const int MOD = 1000000007; /*------------------------------------------------------------------------------*/ void main_() { int N,K; cin >> N >> K; vector<int> a(N); rep(i,0,N) cin >> a[i]; vector<vector<int>> dp(N+1, vector<int>(K+1)); dp[0][0] = 1; rep(i,1,N+1) rep(j,0,K+1) { dp[i][j] = dp[i-1][j]; if(a[i-1] <= j) dp[i][j] += dp[i-1][j-a[i-1]]; } int Ans = dp[N][K]; printf("%lld\n", Ans); }