#include #include #include #include static const int PEOPLE = 100; int main() { int problem_num; std::cin >> problem_num; std::vector score, solved(PEOPLE, 0); for (int i = 0; i < problem_num; i++) { int num; std::cin >> num; score.push_back(num); } for (int i = 0; i < problem_num; i++) { int num; std::cin >> num; solved[num] += score[i]; if (num != 0) score[i] = 0; } solved[0] = 0; //解かれてない問題は集計しない int top_score = *std::max_element(solved.begin(), solved.end()); int player_score = std::accumulate(score.begin(), score.end(), 0); std::cout << (top_score <= player_score ? "YES" : "NO") << std::endl; return 0; }