Submission #96224

#TimeUsernameProblemLanguageResultExecution timeMemory
96224KastandaBank (IZhO14_bank)C++11
100 / 100
69 ms4572 KiB
#include<bits/stdc++.h> using namespace std; const int N = 20, MXN = (1 << N) + 5; int n, m, A[N], B[N], sum[MXN]; vector < int > vec[N]; multiset < int > SS; void Go(int mask, int i) { if (i == n) { printf("YES\n"); exit(0); } for (int mask2 : vec[i]) if ((mask & mask2) == 0) Go(mask ^ mask2, i + 1); } int main() { scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) scanf("%d", &A[i]), SS.insert(A[i]); for (int i = 0; i < m; i++) { scanf("%d", &B[i]); if (SS.count(B[i])) SS.erase(SS.lower_bound(B[i])), i --, m --; } n = 0; for (int a : SS) A[n ++] = a; if (n + n > m) return !printf("NO\n"); for (int i = 1; i < (1 << m); i++) { sum[i] = sum[i ^ (1 << __builtin_ctz(i))] + B[__builtin_ctz(i)]; for (int j = 0; j < n; j++) if (sum[i] == A[j]) vec[j].push_back(i); } Go(0, 0); return !printf("NO\n"); }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~
bank.cpp:22:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &A[i]), SS.insert(A[i]);
         ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
bank.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &B[i]);
         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...