#include #include #include int main(){ int n; std::cin >> n; std::vector score(n), ps(n); for(int i = 0; i < n; i++) std::cin >> score[i]; for(int i = 0; i < n; i++){ int num; std::cin >> num; if(num == 0) ps[i] += score[i]; else ps[1] += score[i]; } if(ps[0] >= *std::max_element(ps.begin(), ps.end())) std::cout << "YES" << std::endl; else std::cout << "NO" << std::endl; return 0; }