Submission #1292934

#TimeUsernameProblemLanguageResultExecution timeMemory
1292934olympolympBank (IZhO14_bank)C++20
100 / 100
257 ms6636 KiB
#include <bits/stdc++.h> using namespace std; int s[21], b[21]; vector<int> c[21]; int main() { int p, k; if (scanf("%d %d", &p, &k) != 2) return 0; for(int i = 0; i < p; i++) scanf("%d", &s[i]); for(int i = 0; i < k; i++) scanf("%d", &b[i]); sort(s, s + p, greater<int>()); int T = 1 << k; vector<int> sum(T, 0); for(int m = 1; m < T; m++) { int bit = __builtin_ctz(m); sum[m] = sum[m ^ (1 << bit)] + b[bit]; } for(int i = 0; i < p; i++) { for(int m = 0; m < T; m++) { if(sum[m] == s[i]) c[i].push_back(m); } } vector<char> E(T, 0); vector<char> Y(T, 0); E[0] = 1; for(int i = 0; i < p; i++) { fill(Y.begin(), Y.end(), 0); for(int m = 0; m < T; m++) { if(E[m]) { for(int x : c[i]) { if((m & x) == 0) { Y[m | x] = 1; } } } } E.swap(Y); } bool ok = false; for(int m = 0; m < T; m++) { if(E[m]) { ok = true; break; } } puts(ok ? "YES" : "NO"); return 0; }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:11:37: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     for(int i = 0; i < p; i++) scanf("%d", &s[i]);
      |                                ~~~~~^~~~~~~~~~~~~
bank.cpp:12:37: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     for(int i = 0; i < k; i++) 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...