제출 #640227

#제출 시각아이디문제언어결과실행 시간메모리
640227Zian_Jacobson은행 (IZhO14_bank)C++17
19 / 100
94 ms8508 KiB
#include<bits/stdc++.h> using namespace std; #define cIO ios_base::sync_with_stdio(0);cin.tie(0) #define fileIO(x) ifstream fin(string(x)+".in"); ofstream fout(string(x)+".out") #define cont(container, object) (container.find(object)!=container.end()) #define sz(x) (int) (x).size() #define ll long long #define v vector int ppl_cvr[1 << 20], leftover[1 << 20]; int N, M; int main() { fill_n(ppl_cvr, 1 << 20, -1); fill_n(leftover, 1 << 20, 0); cin >> N >> M; vector<int> ppl(N, 0); vector<int> notes(M, 0); for (int i = 0; i <= N - 1; i++) cin >> ppl[i]; ppl.push_back(10000000);//to prevent overflow for (int i = 0; i <= M - 1; i++) cin >> notes[i]; for (int msk = 1; msk < (1 << M); msk++) { for (int nt = 0; nt <= M - 1; nt++) { if (msk & (1 << nt)) { if (ppl[ppl_cvr[msk - (1 << nt)] + 1] == notes[nt] + leftover[msk - (1 << nt)])//if exactly enough for the next person { ppl_cvr[msk] = max(ppl_cvr[msk], ppl_cvr[msk - (1 << nt)] + 1); leftover[msk] = 0; } else { ppl_cvr[msk] = max(ppl_cvr[msk], ppl_cvr[msk - (1 << nt)]); leftover[msk] = leftover[msk - (1 << nt)] + notes[nt]; } } } } if (ppl_cvr[(1 << M) - 1] == N - 1) cout << "YES"; else 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...