Submission #68583

#TimeUsernameProblemLanguageResultExecution timeMemory
68583cdemirerBank (IZhO14_bank)C++17
100 / 100
366 ms9208 KiB
#include <bits/stdc++.h> #include <unordered_map> using namespace std; typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ii> vii; typedef vector<vii> vvii; typedef pair<double, double> dodo; #define mp(x, y) make_pair(x, y) #define pb(x) push_back(x) int N, M; int A[20], B[20]; vi masklist[20001]; bool mark[1048576]; void dfs(int pos, int mask) { } int main(int argc, char **argv) { ios_base::sync_with_stdio(0); cin.tie(0); 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 j = 1; j < (1<<M); j++) { int sum = 0; for (int k = 0; k < M; k++) if (j & (1<<k)) sum += B[k]; masklist[sum].pb(j); } int sum = 0; vi masks; for (int i = 0; i < N; i++) { sum += A[i]; masks.clear(); for (int j = 0; j < masklist[sum].size(); j++) { int m = masklist[sum][j]; if (i == 0 || mark[m]) masks.pb(m); } if (masks.empty()) { cout << "NO" << endl; return 0; } memset(mark, 0, sizeof(mark)); for (int i = 0; i < masks.size(); i++) { int m = masks[i]; mark[m] = true; } for (int m = 0; m < (1<<M); m++) { if (mark[m]) for (int k = 0; k < M; k++) { mark[m | (1<<k)] = true; } } } cout << "YES" << endl; return 0; }

Compilation message (stderr)

bank.cpp: In function 'int main(int, char**)':
bank.cpp:42:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = 0; j < masklist[sum].size(); j++) {
                   ~~^~~~~~~~~~~~~~~~~~~~~~
bank.cpp:51:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < masks.size(); 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...