P13277 Adaptation
Description
Little W enjoys adapting problems.
There are two types of adaptations: **problem statement adaptation** and **solution approach adaptation**.
There are $n$ candidate problems, each with an initial quality $a_i$ and two attributes $x_i$ and $y_i$. If $x_i=1$, it means the problem is a **problem statement adaptation**; if $y_i=1$, it means the problem is a **solution approach adaptation**.
When reviewing a problem:
- If it is a **problem statement adaptation**, its perceived quality decreases by $k_1$
- If it is a **solution approach adaptation**, its perceived quality decreases by $k_2$
- If it is both adaptations, it is discarded
- If the perceived quality becomes negative, it is discarded
Find the maximum perceived quality among remaining problems. If all are discarded, output `-1`.
Input Format
First line: three integers $n$, $k_1$, $k_2$
Next $n$ lines: three integers each ($a_i$, $x_i$, $y_i$)
Output Format
Single integer: the maximum perceived quality, or `-1` if all discarded
Explanation/Hint
**Sample Breakdown:**
1. Problem 1: $6$ (no adaptations)
2. Problem 2: $7$ (no adaptations)
3. Problem 3: discarded (both adaptations)
4. Problem 4: $9-1=8$ (statement adaptation)
Maximum quality among remaining: $8$
**Data Range**
For all data $1 \le n \le 10^5$, $1 \le a_i, k_1, k_2 \le 10^9$,$x_i, y_i \in \{0,1\}$,No bundled testing.