Flying Upward (APCS 2021-01 Expert)
2.0s 256MStart at \((0,0)\). Each move may go to a point whose two coordinates are both at least their current values. There are \(n\) fruits; visiting a fruit collects it once. Maximize the number collected.
Input Format
Read \(n\), followed by the coordinate pairs of the fruits.
Output Format
Print the maximum number of fruits.
Constraints
\(1\le n\le200000\); \(1\le x_i,y_i\le10^7\). Coordinate pairs are distinct.
Scoring
- 20 points: \(n\le100,x_i,y_i\le100\).
- 30 points: \(n\le1000\).
- 50 points: No additional restrictions.
Each scored test is worth 5 points.
Sample Input
3
1 1
2 5
3 2
Sample Output
2
Source
APCS 2021-01 public archive version: f608。
Log in to write and submit code.
Log in