제출 #485181

#제출 시각아이디문제언어결과실행 시간메모리
485181XII은행 (IZhO14_bank)C++17
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define fi first #define se second #define mp make_pair #define eb emplace_back #define ALL(x) (x).begin(), (x).end() #define FOR(i, a, b) for(int i = (a); i < (b); ++i) #define FORU(i, a, b) for(int i = (a); i <= (b); ++i) #define FORD(i, a, b) for(int i = (a); i >= (b); --i) #define IOS cin.tie(0)->sync_with_stdio(false); #define PROB "IZhO14_bank" void Fi(){ if(fopen(PROB".inp", "r")){ freopen(PROB".inp", "r", stdin); freopen(PROB".out", "w", stdout); } } const int N = 20; const int V = 1000 + 1; bool dp[1 << N][N + 1]; vector<int> adj[V]; int n, m; int a[N], b[N]; int main(){ IOS; Fi(); cin >> n >> m; FORU(i, 1, n) cin >> a[i]; FOR(i, 0, m) cin >> b[i]; FOR(mask, 1, 1 << m){ int sum = 0; FOR(i, 0, m) if(mask & (1 << i)) sum += b[i]; if(sum < N) adj[sum].eb(mask); } dp[0][0] = true; FORU(i, 1, n){ FOR(mask, 1, 1 << m){ for(int s: adj[a[i]]) if((mask & s) == s){ dp[mask][i] |= dp[mask ^ s][i - 1]; } } } bool ans = false; FOR(mask, 1, 1 << m) ans |= dp[mask][n]; if(ans) cout << "YES"; else cout << "NO"; return 0; }

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

bank.cpp: In function 'void Fi()':
bank.cpp:20:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         freopen(PROB".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:21:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         freopen(PROB".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...