#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { int n; cin >> n; int score = 0; int a[n], b[n]; map memo; int maxv = 0; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { cin >> b[i]; } for (int i = 0; i < n; i++) { if (b[i] == 0) { score += a[i]; }else { memo[a[i]] += b[i]; maxv = max(maxv, memo[a[i]]); } } if (score >= maxv) { std::cout << "YES" << std::endl; }else { std::cout << "NO" << std::endl; } }