#B3999. Drum Factory Scheduling Problem
Drum Factory Scheduling Problem
Drum Factory Scheduling Problem
Little Su is the director of a drum factory. The factory has \(n\) machines, where the \(i\)-th machine can produce \(a_i\) drums in one day. Due to environmental, financial, and maintenance constraints, only one machine can be used each day over the next \(n\) days, and each machine can only be used once.
Simultaneously, there are \(n\) orders. The \(i\)-th order requires \(b_i\) drums. Determine whether there exists a feasible assignment of machines to days and a sequence for order deliveries so that each day, the machine used produces at least as many drums as required by the corresponding order.
In other words, is it possible to reorder both arrays \(a\) and \(b\) such that for every \(i\) (\(1 \le i \le n\)) we have \(a'_i \ge b'_i\)?
inputFormat
The first line contains a single integer \(n\) \((1 \le n \le 10^5)\) representing the number of machines and orders.
The second line contains \(n\) space-separated integers \(a_1, a_2, \dots, a_n\) \((1 \le a_i \le 10^9)\), where \(a_i\) is the number of drums produced by the \(i\)-th machine in one day.
The third line contains \(n\) space-separated integers \(b_1, b_2, \dots, b_n\) \((1 \le b_i \le 10^9)\), where \(b_i\) is the required number of drums for the \(i\)-th order.
outputFormat
Output a single line containing "YES" if there exists an assignment that satisfies the daily order requirements, or "NO" otherwise.
sample
3
3 1 2
1 2 3
YES