# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
723398 | 2023-04-13T17:20:57 Z | quochuy147 | 은행 (IZhO14_bank) | C++14 | 3 ms | 340 KB |
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define ll long long #define mp make_pair #define pb push_back #define pii pair<int, int> #define pll pair<ll, ll> #define MASK(i) (1LL << (i)) #define BIT(x, i) (((x) >> (i)) & 1) #define file "bank" template <typename T1, typename T2> bool minimize(T1 &a, T2 b){if (a > b) {a = b; return true;} return false;} template <typename T1, typename T2> bool maximize(T1 &a, T2 b){if (a < b) {a = b; return true;} return false;} const int mod = 1e9 + 7; const int N = 20; int n, m; int a[N + 5], b[N + 5]; pii f[MASK(N) + 5]; void inp() { cin >> n >> m; for(int i = 1; i <= n; ++i) cin >> a[i]; for(int i = 1; i <= m; ++i) cin >> b[i]; } void solve() { // memset(f, -1, sizeof f); for(int i = 1; i < MASK(m); ++i) f[i].fi = -1; f[0] = {1, 0}; for(int i = 1; i < MASK(m); ++i) for(int j = 1; j <= m; ++j) { if(MASK(j - 1) & i) { int pre = MASK(j - 1) ^ i; if(f[pre].fi == -1) continue; int cnt = f[pre].fi, val = f[pre].se; if(val + b[j] < a[cnt]) f[i] = {f[pre].fi, val + b[j]}; if(val + b[j] == a[cnt]) f[i] = {f[pre].fi + 1, 0}; if(f[i].fi > n) { cout << "YES"; return ; } } } cout << "NO"; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); freopen(file".in" , "r" , stdin); freopen(file".out" , "w" , stdout); inp(); solve(); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |