Submission #1030700

#TimeUsernameProblemLanguageResultExecution timeMemory
1030700ziewaczBank (IZhO14_bank)C++17
44 / 100
273 ms80468 KiB
#include <bits/stdc++.h> #define imie(x...) cerr << "[" #x "]: ", [](auto... $) {((cerr << $ << "; "), ...); }(x), cerr << '\n' using namespace std; typedef long long ll; typedef long double ld; const int MOD = 1000000007; vector<vector<int>> gen(const vector<int>& a, int n) { vector<vector<int>> podzbiory; for (int maska = 0; maska < (1 << n); maska++) { vector<int> podzbior; for (int i = 0; i < n; i++) { if (maska & (1 << i)) { podzbior.push_back(a[i]); } } sort(podzbior.begin(), podzbior.end()); podzbiory.push_back(podzbior); } return podzbiory; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; map<int, int> goscie; for (int i = 0; i < n; i++) { int x; cin >> x; goscie[x]++; } vector<int> v(m); for (int i = 0; i < m; i++) { cin >> v[i]; } vector<vector<int>> a = gen(v, m); int ile = 0; vector<bool> visited(m, false); for (auto &podzbior : a) { int S = accumulate(podzbior.begin(), podzbior.end(), 0); if (S != 0 && goscie.find(S) != goscie.end()) { bool ok = true; vector<int> uzyte; for (auto &i : podzbior) { for (int j = 0; j < m; j++) { if (v[j] == i && !visited[j]) { uzyte.push_back(j); break; } } } if (uzyte.size() == podzbior.size()) { for (auto &idx : uzyte) { visited[idx] = true; } goscie[S]--; if (goscie[S] == 0) { goscie.erase(S); } ile++; } } } cout << ((ile == n) ? "YES" : "NO"); return 0; }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:47:18: warning: unused variable 'ok' [-Wunused-variable]
   47 |             bool ok = true;
      |                  ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...