Submission #873289

#TimeUsernameProblemLanguageResultExecution timeMemory
873289asdasdqwerBank (IZhO14_bank)C++17
71 / 100
825 ms262144 KiB
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define int int64_t signed main() { clock_t start = clock(); int n, m;cin>>n>>m; vector<int> a(n); for (int &x:a)cin>>x; vector<int> b(m); for (int &x:b)cin>>x; sort(a.begin(), a.end()); sort(b.begin(), b.end()); vector<vector<int>> bitmasks; for (int i=0;i<n;i++) { vector<int> btm; int x = a[i]; int mx = (1 << m); for (int j=1;j<mx;j++) { int sm = 0, cp = j; int cnt=0; while (cp) { if ((cp & 1) == 1) { sm += b[m-cnt-1]; if (sm > x) break; } cnt++; cp >>= 1; } if (sm == x) { btm.push_back(j); } } if (btm.size() == 0) { cout << "NO\n"; return 0; } bitmasks.push_back(btm); } vector<int> ger; for (int x:bitmasks[0]) { ger.push_back(x); } for (int i=1;i<n;i++) { vector<int> copy; for (int x:bitmasks[i]) { for (int y:ger) { if ((x & y) == 0) { copy.push_back((x | y)); } } } ger = copy; } if (ger.size()) { cout << "YES\n"; } else { cout << "NO\n"; } clock_t end = clock(); double dif = ((double)end - (double)start) / CLOCKS_PER_SEC; // cout << dif << "\n"; }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:78:12: warning: unused variable 'dif' [-Wunused-variable]
   78 |     double dif = ((double)end - (double)start) / CLOCKS_PER_SEC;
      |            ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...