Submission #590787

#TimeUsernameProblemLanguageResultExecution timeMemory
590787MazaalaiBank (IZhO14_bank)C++17
100 / 100
123 ms4408 KiB
#include <bits/stdc++.h> #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,bits") #pragma GCC target("avx2") #define ff first #define ss second using namespace std; using sint = short int; using PII = pair <sint, sint>; signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); sint n, m; cin >> n >> m; sint a[n], b[m]; PII dp[1<<m]; for (sint i = 0; i < n; i++) cin >> a[i]; for (sint i = 0; i < m; i++) cin >> b[i]; sort(a, a+n); sort(b, b+m); dp[0] = {0, 0}; bool done = 0; for (int i = 1; i < (1<<m) && !done; i++) { dp[i] = {0, 0}; for (sint j = 0; j < m; j++) { if (!(i & (1<<j)) || dp[i].ff > dp[i^(1<<j)].ff) continue; PII& tmp = dp[i^(1<<j)]; if (tmp.ff > dp[i].ff) dp[i] = tmp; if (a[tmp.ff] >= b[j]+tmp.ss && dp[i].ss < b[j]+tmp.ss) dp[i].ss = b[j]+tmp.ss; } if (dp[i].ss == a[dp[i].ff]) dp[i] = {dp[i].ff+1, 0}; done |= dp[i].ff == n; } cout << (done ? "YES" : "NO") << "\n"; }

Compilation message (stderr)

bank.cpp:2:76: warning: bad option '-fbits' to pragma 'optimize' [-Wpragmas]
    2 | #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,bits")
      |                                                                            ^
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
    3 | #pragma GCC target("avx2")
      |                          ^
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [-Wattributes]
bank.cpp:3:26: warning: bad option '-fbits' to attribute 'optimize' [
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...