Submission #37843

#TimeUsernameProblemLanguageResultExecution timeMemory
37843Just_Solve_The_ProblemBank (IZhO14_bank)C++11
100 / 100
194 ms1784 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back const int N = (int)22; const int NN = (1 << 20); int a[N], b[N]; bool used[NN]; int n, m; vector < int > vec[N]; void go (int pos, int mask) { if (used[mask]) return ; used[mask] = 1; if (pos == n) { puts("YES"); exit(0); } for (int to : vec[pos]) { if (mask & to) continue; go(pos + 1, mask | to); } } main () { scanf ("%d %d", &n, &m); for (int i = 0; i < n; i++) { scanf ("%d", a + i); } for (int i = 0; i < m; i++) { scanf ("%d", b + i); } for (int mask = 0; mask < (1 << m); mask++) { int sum = 0; for (int j = 0; j < m; j++) { if (mask & (1 << j)) { sum += b[j]; } } for (int j = 0; j < n; j++) { if (sum == a[j]) { vec[j].pb(mask); } } } go(0, 0); puts("NO"); }

Compilation message (stderr)

bank.cpp:28:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main () {
       ^
bank.cpp: In function 'int main()':
bank.cpp:29:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d %d", &n, &m);
     ~~~~~~^~~~~~~~~~~~~~~~~
bank.cpp:31:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf ("%d", a + i);
         ~~~~~~^~~~~~~~~~~~~
bank.cpp:34:15: 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...