#C5062. Inventory Management Challenge
Inventory Management Challenge
Inventory Management Challenge
In this problem, you are given multiple test cases where each test case represents an inventory delivery followed by sales transactions. For each test case, you need to determine whether every sale can be completed with the available inventory. For each item, the inventory is the sum of all delivered quantities. A sale is valid if and only if the available inventory for that item is at least as much as the quantity sold. Formally, for each item \(i\), the condition is:
\( inventory_i \geq sales_i \)
If all sale transactions satisfy this condition, output YES
for that test case; otherwise, output NO
.
inputFormat
The input begins with an integer \(T\) representing the number of test cases. Each test case is described as follows:
- The first line contains two integers \(N\) and \(M\), denoting the number of delivery records and the number of sales transactions, respectively.
- The next \(N\) lines each contain two integers: an item ID and the delivered quantity for that item.
- The following \(M\) lines each contain two integers: an item ID and the quantity sold.
All input is provided via stdin.
outputFormat
For each test case, output a single line with either YES
or NO
. Output is written to stdout.
1
2 2
101 10
102 20
101 5
102 15
YES