Submission #674728

#TimeUsernameProblemLanguageResultExecution timeMemory
674728MinhOnePunchBank (IZhO14_bank)C++17
19 / 100
81 ms8508 KiB
#include <bits/stdc++.h> #define time_run cerr << 1.0*clock()/CLOCKS_PER_SEC << "\n" #define fdto(i, a, b) for(int i = (int)a; i >= (int)b; --i) #define fto(i, a, b) for(int i = (int)a; i <= (int)b; ++i) #define all(x) x.begin(), x.end() #define pb push_back #define ss second #define ff first #define endl '\n' using namespace std; using db = double; using ll = long long; using ii = pair<int, int>; using llll = pair<ll, ll>; const long long ooo = (ll)1e18 + 7; const int mod = (int)1e9 + 7, oo = (int)1e9 + 7; #define name "cpp" #define maxM (int)1e + 5 #define maxN (int)2e1 + 5 int n, m, a[maxN], b[maxN], f[(1<<20)+5], du[(1<<20)+5]; int main(){ // freopen(name".in", "r", stdin); //freopen(name".out", "w", stdout); ios::sync_with_stdio(false), cin.tie(nullptr); cin >> n >> m; fto(i, 0, n-1) cin >> a[i]; fto(i, 0, m-1) cin >> b[i]; fto(mask, 0, (1 << m)-1){ fto(bit, 0, m-1){ if (mask >> bit & 1){ int pre = mask ^ (1 << bit); int d = du[pre] + b[bit]; int need = a[f[pre]]; if (d < need){ f[mask] = f[pre]; du[mask] = d; } else if (d == need){ f[mask] = f[pre] + 1; du[mask] = 0; } } } if (f[mask] == n){ cout << "YES" << endl; return 0; } } cout << "NO" << endl; return (0-0); // winhonepunch <3s /* random_shuffle(v.begin(), v.end()): shuffles the order of the elements bitset<10^9 + 1> vẫn hợp lệ do mỗi bit chỉ chiếm 1 bit => 128 MB struct cmp{ // cmp for set bool operator()(const type& x, const type& y) const { return x. < y.; } }; __builtin_popcount(x) đếm số bit 1 trong x O(1) bitset.to_ulong() chuyển từ bitset sang số map should use for(const auto& it: map) a += b better than a = a + b; 1 hour -> tags -> each hint -> code */ }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...