# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
973462 |
2024-05-02T03:26:34 Z |
amirujuz |
Bank (IZhO14_bank) |
C++14 |
|
5 ms |
16744 KB |
#include <bits/stdc++.h>
#define allr v.rbegin(), v.rend()
#define sllr s.rbegin(), s.rend()
#define all v.begin(), v.end()
#define sll s.begin(), s.end()
#define pii pair <int, int>
#define int long long
#define pb push_back
#define pp pop_back
#define sc second
#define fr first
using namespace std;
const int N=1e3+7, INT=1e6+7, X=2097152, INf=1e9+7, INF=INT64_MAX;
signed main() {
ios_base::sync_with_stdio(false);
cout.tie(NULL);
cin.tie(NULL);
int n, m, i, mask, sum;
cin >> n >> m;
vector <int> v(n), k(m), dp(X), p[n];
map <int, int> mp;
for (i=0; i<n; i++) {
cin >> v[i];
}
for (i=0; i<m; i++) {
cin >> k[i];
}
for (mask=0; mask<1<<m; mask++) {
sum=0;
for (i=0; i<m; i++) {
if (mask&(1<<i)) {
sum+=k[i];
}
}
for (i=0; i<n; i++) {
if (v[i]==sum) p[i].pb(mask);
}
}
for (i=1; i<X; i++) {
dp[i]=-1;
}
for (i=0; i<n; i++) {
for (mask=1<<m-1; mask>=0; mask--) {
for (auto j: p[i]) {
if (dp[mask]!=-1 && !mask&j) {
dp[mask|j]=dp[mask]+1;
if (dp[mask|j]==n) {
cout << "YES";
return 0;
}
}
}
}
}
cout << "NO";
}
Compilation message
bank.cpp: In function 'int main()':
bank.cpp:43:17: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
43 | for (mask=1<<m-1; mask>=0; mask--) {
| ~^~
bank.cpp:45:25: warning: suggest parentheses around operand of '!' or change '&' to '&&' or '!' to '~' [-Wparentheses]
45 | if (dp[mask]!=-1 && !mask&j) {
| ^~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
16732 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
16732 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
16744 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
16732 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |