Submission #340078

#TimeUsernameProblemLanguageResultExecution timeMemory
340078_aniBank (IZhO14_bank)C++17
0 / 100
2 ms1024 KiB
#include <iostream> #include <algorithm> #include <vector> using namespace std; vector<int> dp[22], sums[20'002]; int a[22], b[22]; int n, m; int getsum(int mask) { int res = 0; int ind = m - 1; while (mask) { if (mask & 1) res += b[ind]; mask >>= 1; ind--; } return res; } int main() { cin >> n >> m; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < m; i++) cin >> b[i]; for (int i = 1; i < (1 << m); i++) sums[getsum(i)].push_back(i); swap(sums[a[0]], dp[0]); for (int i = 1; i < n; i++) for (int j = 0; j < dp[i - 1].size(); j++) { if (!dp[i - 1].empty()) { cout << "NO\n"; return 0; } for (int k = 0; k < sums[a[i]].size(); k++) if ((dp[i - 1][j] & sums[a[i]][k]) == 0) dp[i].push_back(dp[i - 1][j] | sums[a[i]][k]); } cout << "YES\n"; return 0; }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:32:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   for (int j = 0; j < dp[i - 1].size(); j++)
      |                   ~~^~~~~~~~~~~~~~~~~~
bank.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |    for (int k = 0; k < sums[a[i]].size(); k++)
      |                    ~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...