제출 #388335

#제출 시각아이디문제언어결과실행 시간메모리
388335Qw3rTy은행 (IZhO14_bank)C++11
100 / 100
91 ms8532 KiB
#include <bits/stdc++.h> #define pi pair<int,int> #define fi first #define se second using namespace std; const int maxN = 20+2; void testIO(){ freopen("../test.in","r",stdin); return; } pi f[(1<<maxN)]; int a[maxN]; int b[maxN]; int N,M; signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); //testIO(); cin >> N >> M; for(int i = 1; i <= N; ++i)cin >> a[i]; a[N+1] = 0; for(int i = 1; i <= M; ++i)cin >> b[i]; f[0].fi = 1; f[0].se = a[1]; for(int i = 0; i < (1<<M); ++i){ for(int j = 1; j <= M; ++j){ if((i&(1<<(j-1))) != 0)continue; //banknote j is already used if(b[j] > f[i].se)continue; //the banknote is too large if(b[j] == f[i].se){ //刚刚好 f[i|(1<<(j-1))].fi = f[i].fi + 1; if(f[i|(1<<(j-1))].fi == (N+1)){ cout << "YES" << '\n'; return 0; } f[i|(1<<(j-1))].se = a[f[i].fi+1]; } else{ f[i|(1<<(j-1))].fi = f[i].fi; f[i|(1<<(j-1))].se = f[i].se - b[j]; } } } cout << "NO" << '\n'; return 0; }

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

bank.cpp: In function 'int main()':
bank.cpp:23:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   23 |     for(int i = 1; i <= N; ++i)cin >> a[i]; a[N+1] = 0;
      |     ^~~
bank.cpp:23:45: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   23 |     for(int i = 1; i <= N; ++i)cin >> a[i]; a[N+1] = 0;
      |                                             ^
bank.cpp: In function 'void testIO()':
bank.cpp:10:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   10 |     freopen("../test.in","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...