#include #include using namespace std; int main() { int N, K = 0, s[101] = { 0 }; cin >> N; vector a(N), b(N); 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) K += a[i]; else s[b[i]] += a[i]; } for (int i = 0; i <= 100; i++) { if (K < s[i]) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; return 0; }