제출 #1124849

#제출 시각아이디문제언어결과실행 시간메모리
1124849njoop은행 (IZhO14_bank)C++17
0 / 100
3 ms4424 KiB
#include <bits/stdc++.h> using namespace std; int cov[2000010], mon[2000010], notes[30], ppl[30], n, m; int main() { cin >> n >> m; for(int i=1; i<=n; i++) { cin >> ppl[i]; } for(int i=1; i<=m; i++) { cin >> notes[i]; } for(int i=0; i<=(1<<20); i++) { cov[i] = -1; } cov[0] = 0; for(int i=0; i<(1<<m); i++) { for(int j=0; j<m; j++) { if(i & (1 << j) == 0) continue; int pre = i & ~(1 << j); if(cov[pre] == -1) continue; if(mon[pre]+notes[j+1] < ppl[cov[pre]+1]) { cov[i] = cov[pre]; mon[i] = mon[pre]+notes[j+1]; } else if(mon[pre]+notes[j+1] == ppl[cov[pre]+1]) { cov[i] = cov[pre]+1; mon[i] = 0; } } if(cov[i] == n) { cout << "YES"; return 0; } } cout << "NO"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...