#include #include #include using namespace std; int main(){ int n; cin >> n; vector data1(n); vector data2(n); vector score(101); for(auto &a:data1) cin >> a; for(auto &b:data2) cin >> b; int count = 0; for(int i = 0; i < n; i++){ if(data2[i] == 0) count += data1[i]; else score[data2[i]] += data1[i]; } /* for(int i = 0; i < n; i++){ if(count < score[data2[i]]){ cout << "NO" << endl; return 0; } } */ sort(score.begin(),score.end()); cout << (count >= score[100] ? "YES" : "NO") << endl; return 0; }