제출 #1001426

#제출 시각아이디문제언어결과실행 시간메모리
1001426reginox은행 (IZhO14_bank)C++17
52 / 100
1100 ms6492 KiB
#include<bits/stdc++.h> #define ll long long #define ld long double #define all(v) begin(v), end(v) #define pi pair<int, int> #define vi vector<int> #define task "test" using namespace std; const int maxn = 20; int n, m, a[maxn], b[maxn]; bool dp[maxn][1<<maxn]; vector<int> cnt[maxn]; int main(){ if(fopen(task".inp","r")){ freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 0; i < m; i++) cin >> b[i]; for(int i = 0; i < 1<<m; i++){ int sum = 0; for(int j = 0; j < m; j++){ if(i & (1<<j)) sum += b[j]; } for(int j = 1; j <= n; j++){ if(sum == a[j]) cnt[j].push_back(i); } } dp[0][0] = true; for(int i = 0; i < 1<<m; i++){ // cerr << i << "\n"; for(int j = 1; j <= n; j++){ // cerr << j << " "; for(auto x:cnt[j]){ if(x > i) break; // cerr << x << " "; if((x & i) == x){ dp[j][i] |= dp[j-1][i-x]; } } } // cerr << "\n"; } for(int i = 0; i < 1<<m; i++){ if(dp[n][i]){ cout << "YES"; return 0; } } cout << "NO"; return 0; }

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

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