제출 #528172

#제출 시각아이디문제언어결과실행 시간메모리
528172CursedCode은행 (IZhO14_bank)C++14
0 / 100
1 ms204 KiB
#include<bits/stdc++.h> using namespace std; int covered[(1<<20)] = {-1},leftover[(1<<20)] = {-1}; int main(){ int n,m,i,j,a[21],b[21]; cin >> n >> m; for(i = 0;i < n;i++){ cin >> a[i]; } sort(a,a+n); for(i = 0;i < m;i++){ cin >> b[i]; } leftover[0] = 0; covered[0] = 0; for(i = 1;i < (1 << m);i++){ for(j = 0;j < m;j++){ if(!i & (1 << j)){ int ih = i ^ (1 << j); if(covered[ih] == -1) continue; if(leftover[ih] + b[j] < a[covered[ih]]){ leftover[i] = leftover[ih] + b[j]; covered[i] = covered[ih]; } if(leftover[ih] + b[j] < a[covered[ih]]){ leftover[i] = leftover[ih] + b[j]; covered[i] = covered[ih]; } if(leftover[ih] + b[j] == a[covered[ih]]){ leftover[i] = 0; covered[i] = covered[ih] + 1; } //cout << i << ' ' << covered[i] << ' ' << leftover[i] << ' ' << j << endl; } } if(covered[i] == n){ cout << "YES"; return 0; } } cout << "NO"; }

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

bank.cpp: In function 'int main()':
bank.cpp:19:7: warning: suggest parentheses around operand of '!' or change '&' to '&&' or '!' to '~' [-Wparentheses]
   19 |    if(!i & (1 << j)){
      |       ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...