제출 #723398

#제출 시각아이디문제언어결과실행 시간메모리
723398quochuy147은행 (IZhO14_bank)C++14
0 / 100
3 ms340 KiB
#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; }

컴파일 시 표준 에러 (stderr) 메시지

bank.cpp: In function 'int main()':
bank.cpp:58:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |     freopen(file".in" , "r" , stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:59:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   59 |     freopen(file".out" , "w" , stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...