Submission #1100399

#TimeUsernameProblemLanguageResultExecution timeMemory
1100399AlirezaBank (IZhO14_bank)C++17
100 / 100
76 ms4512 KiB
#include<bits/stdc++.h> using namespace std; const int N = 25; int n, m, a[N], b[N], dp[1 << N], sum[N]; void solve() { for (int i = 0; i < n; i++) sum[i + 1] = sum[i] + a[i]; for (int msk = 0; msk < (1 << m); msk++) { int s = 0; for (int i = 0; i < m; i++) if ((msk >> i) & 1) dp[msk] = max(dp[msk], dp[msk ^ (1 << i)]), s += b[i]; dp[msk] += (s == sum[dp[msk] + 1]); } cout << (dp[(1 << m) - 1] == n? "YES": "NO"); } void read() { cin >> n >> m; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < m; i++) cin >> b[i]; } int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); read(), solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...