#include #include #include using namespace std; int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); int n; cin >> n; vector a; for (int i = 0; i < n; ++i) { int temp; cin >> temp; a.push_back(temp); } vector b; vector othersScore(101, 0); for (int i = 0; i < n; ++i) { int temp; cin >> temp; b.push_back(temp); if (temp != 0) { othersScore.at(temp) += a.at(i); } } int myScore = 0; for (int i = 0; i < n; ++i) { if (b.at(i) == 0) { myScore += a.at(i); } } if (myScore >= *max_element(othersScore.begin(), othersScore.end())) { cout << "YES" << endl; } else { cout << "NO" << endl; } return 0; }