Foreign Trip
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian.
More and more countries are reopening their borders after the burdock-virus pandemic. Marichka and Zenyk decided to go on a trip with their friends. For this, they all need to get vaccinated.
Friends went to the clinic, stood in a giant queue, and bought a large box of vaccines — \(x\) doses of the first type and \(y\) doses of the second type. Now, each of the \(n\) participants of the trip needs to decide which type of vaccine they will be inoculated with. It is known that the benefit of vaccinating the \(i\)-th participant of the group with the first type of vaccine is \(a_i\), and with the second type of vaccine — \(b_i\).
The friends want to distribute the vaccines among the participants so that each participant receives exactly one dose of vaccine and the total benefit is maximized. Will you help them?
Input
The first line contains three integers \(n\), \(x\), and \(y\) — the number of trip participants, the number of doses of the first type, and the number of doses of the second type.
Each of the next \(n\) lines contains two integers \(a_i\) and \(b_i\) — the benefit of vaccinating the corresponding participant with each of the vaccine types.
Output
Print a single line of \(n\)
characters. The \(i\)-th character
should be A if the \(i\)-th participant should take the first
type of vaccine, and B for the second. If there are several
ways to achieve the maximum benefit, print any of them.
Constraints
\(1 \le n \le 10^5\),
\(0 \le x, y \le 2 \cdot 10^5\),
\(x+y \ge n\),
\(0 \le a_i, b_i \le 10^9\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 4 2 2 1 3 7 4 9 2 3 3 | BAAB |
Notes
The total benefit will be 22. A larger value cannot be achieved.
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|