//inlclude前用define #define _USE_MATH_DEFINES //include #include #include #include #include #include using namespace std; //typedef typedef vector VI; typedef vector VS; typedef vector VC; int main() { int n; cin >> n; VI a(n), b(n); VI s(101); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) cin >> b[i]; int sum = 0; for (int i = 0; i < n; i++) { if (b[i] == 0) sum += a[i]; else s[b[i]] += a[i]; } bool flag = true; for (int i = 0; i < 101; i++) { if (s[i] > sum) flag = false; } if (flag) cout << "YES" << endl; else cout << "NO" << endl; return 0; }