# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
304400 | 2020-09-21T09:28:36 Z | Masalmah | Packing Biscuits (IOI20_biscuits) | C++14 | 0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; #define all(v) (v).begin(), (v).end() #define int long long #define sz(v) (int)(v).size() #define mod 998244353 const int N= 100001; int dp[N]; void solve() { int k, x; cin >> k>> x; vector<int> v(k); for (auto& i: v) cin >> i; dp[0]= 1; for (int i= 0; i< k; i++) { int cnt= (1<< i); for (int kk= 0; kk< N; kk++) { if (dp[kk]==(i+ 1)) { for (int j= 1; j<= v[i]; j++){ if(dp[kk+ (j* cnt)]== 0) dp[kk+ (j* cnt)]= i+ 2; } } } } int an= 0; for (int i= 0; i< N; i++) if (dp[i]) an++; cout << an<< "\n"; } int32_t main(){ ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL); int T= 1; cin >> T; while ( T-- ) { solve(); } return 0; }