# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
478254 | 2021-10-06T17:52:48 Z | Kitonds | Bank (IZhO14_bank) | C++17 | 1 ms | 460 KB |
#include <bits/stdc++.h> using namespace std; #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #define read(A) freopen((A + ".in").c_str(),"r",stdin) #define write(A) freopen((A + ".out").c_str(),"w",stdout) #define ll long long #define pb push_back #define ull unsigned long long #define int long long #define f first #define s second #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, ii> iii; typedef vector<iii> viii; constexpr int pct(int x) { return __builtin_popcount(x); } const int DFS_WHITE = 0; const int DFS_BLACK = 1; const int INF = 1e18; const int MAXN = 3e5 + 10; const int MOD = 1e9 + 7 ; void setIO(string filename = ""){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); if(filename.size() == 0) return; read(filename); write(filename); } int n, m, k; void solve(){ cin>>n>>m; vi A(n), B(m); for (int i=0; i<n; i++){ cin>>A[i]; } for (int i=0; i<m; i++){ cin>>B[i]; } vi cover(1 << m, -1); vi left(1 << m, -1); cover[0] = 0; left[0] = 0; for (int i=0; i<(1<<m); i++){ for (int j=0; j<m; j++){ if (i & (1 << j) == 0){ continue; } int prev = i & (~(1 << j)); if (cover[prev] == -1){ continue; } int tmp = left[prev] + B[j]; int cur = A[cover[prev]]; if (tmp < cur){ cover[i] = cover[prev]; left[i] = tmp; } else if (tmp == cur){ cover[i] = cover[prev] + 1; left[i] = 0; } } // / cout<<i<<" "<<cover[i]<<endl; if (cover[i] == n){ cout<<"YES"; return; } } cout<<"NO"; } int tc = 1; signed main() { setIO(); int test = 1; // cin>>test; while(test--){ solve(); cout<<endl; tc++; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Incorrect | 0 ms | 204 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 460 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |