Submission #563270

#TimeUsernameProblemLanguageResultExecution timeMemory
563270tamthegodBank (IZhO14_bank)C++14
100 / 100
723 ms82404 KiB
#include<iostream> #include<iomanip> #include<algorithm> #include<stack> #include<queue> #include<string> #include<string.h> #include<cmath> #include<vector> #include<map> #include<unordered_map> #include<set> #include<unordered_set> #include<cstdio> #include<bitset> #include<chrono> #include<random> #include<ext/rope> /* ordered_set #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> */ #define pb push_back #define fi first #define se second using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int maxN = 20 + 5; const int mod = 1e9 + 7; const ll oo = 1e18; int n, m, a[maxN], b[maxN]; int f[maxN][1 << 20]; void ReadInput() { cin >> n >> m; for(int i=1; i<=n; i++) cin >> a[i]; for(int i=1; i<=m; i++) cin >> b[i]; } void Solve() { for(int i=1; i<=n; i++) { vector<int> vc; for(int mask=0; mask<(1<<m); mask++) f[i][mask] = f[i - 1][mask]; for(int mask=0; mask<(1<<m); mask++) { if(f[i][mask] == -1) continue; int sum = 0; for(int j=1; j<=m; j++) { if(!(mask & (1 << (j - 1)))) f[i][mask | (1 << (j - 1))] = f[i][mask] + b[j]; } } // cout << f[1][20];return; for(int mask=0; mask<(1<<m); mask++) f[i][mask] = f[i][mask] == a[i] ? 0 : -1; } for(int i=0; i<(1<<m); i++) if(!f[n][i]) { cout << "YES"; return; } cout << "NO"; } int32_t main() { //freopen("x.inp", "r", stdin); ios_base::sync_with_stdio(false); cin.tie(nullptr); ReadInput(); Solve(); }

Compilation message (stderr)

bank.cpp: In function 'void Solve()':
bank.cpp:54:17: warning: unused variable 'sum' [-Wunused-variable]
   54 |             int sum = 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...