제출 #1136358

#제출 시각아이디문제언어결과실행 시간메모리
1136358classic은행 (IZhO14_bank)C++20
0 / 100
36 ms24388 KiB
// mode: short code /* practicing.. */ #include<bits/stdc++.h> int main() { freopen("bank.in", "r", stdin); freopen("bank.out", "w", stdout); std::ios::sync_with_stdio(false); std::cin.tie(0); int n, m; std::cin >> n >> m; std::vector<int> a(n); for (int i = 0; i < n; i++) { std::cin >> a[i]; } std::vector<int> b(m); for (int i = 0; i < m; i++) { std::cin >> b[i]; } std::vector<int> cnt(1 << m, -1), rem(1 << m, -1); cnt[0] = 0; rem[0] = 0; for (int i = 1; i < (1 << m); i++) { for (int j = 0; j < m; j++) { if (!(i & (1 << j))) { continue; } int p = (i ^ (1 << j)); if (cnt[p] == -1) { continue; } int nxt = rem[p] + b[j]; int need = a[cnt[p]]; if (nxt < need) { cnt[i] = cnt[p]; rem[i] = nxt; } else if (nxt == need) { cnt[i] = cnt[p] + 1; rem[i] = 0; } } if (cnt[i] == n) { std::cout << "YES"; return 0; } } std::cout << "NO"; return 0; }

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

bank.cpp: In function 'int main()':
bank.cpp:8:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     freopen("bank.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:9:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     freopen("bank.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...