Submission #1089452

#TimeUsernameProblemLanguageResultExecution timeMemory
1089452vjudge1Bank (IZhO14_bank)C++17
0 / 100
1 ms360 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n, m; cin >> n >> m; vector<int> valores(m); vector<int> notas(m); for (int i = 0; i < m; i++) { cin >> valores[i]; } for (int i = 0; i < m; i++) { cin >> notas[i]; } vector<int> residual(1 << m, -1); vector<int> cobertos(1 << m, -1); residual[0] = 0; cobertos[0] = 0; int possivel = 0; for (int s = 0; s < (1 << m); s++) { for (int p = 0; p < m; p++) { if ((s & (1 << p)) == 0) continue; int ant = s & ~(1 << p); if (cobertos[ant] == -1) continue; int novo = residual[ant] + notas[p]; if (cobertos[ant] < n) { int alvo = valores[cobertos[ant]]; if (novo < alvo) { cobertos[s] = cobertos[ant]; residual[s] = novo; } else if (novo == alvo) { cobertos[s] = cobertos[ant] + 1; residual[s] = 0; } } } if (cobertos[s] == n) { possivel = 1; } } if (possivel == 1) { cout << "YES" << endl; } else { cout << "NO" << endl; } 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...