Background
Translated from ROI 2018 Day1 T3. Иннофон (Innophone)。
Problem Description
There is a binary function f(x,y) defined as follows:
$f(x,y)=\left\{
\begin{array}{rcl}
a, & & {\text{if} \quad \quad \ \ \ a \leq x}\\
b, & & {\text{else if} \quad b \leq y}\\
0, & & {\text{else}}
\end{array} \right.$
Here a,b are constants. You are given n pairs (x,y). You need to choose suitable a,b so that ∑i=1nf(xi,yi) is maximized.
The first line contains an integer n, the number of pairs (x,y).
The next n lines each contain two numbers xi and yi.
Output one number on one line: max(∑i=1nf(xi,yi)).
5
80 20
60 50
40 40
15 10
70 30
220
1
50 0
50
Hint
For 100% of the testdata, 0≤yi≤xi≤109, 1≤n≤1.5×105.
| Subtask ID |
n |
x,y |
| 1 |
1≤n≤100 |
0≤yi≤xi≤100 |
| 2 |
1≤n≤300 |
0≤yi≤xi≤109 |
| 3 |
1≤n≤3000 |
| 4 |
1≤n≤105 |
yi=0 |
| 5 |
xi=yi |
| 6 |
1≤n≤50000 |
0≤yi≤xi≤109 |
| 7 |
1≤n≤75000 |
| 8 |
1≤n≤105 |
| 9 |
1≤n≤1.25×105 |
| 10 |
1≤n≤1.5×105 |
Translated by ChatGPT 5