IxlOA #2
Growth in 2 Dimensions
Estimated EasyJudge-ready
Topics (AI-labelled)Bits & MathIn-place Arrays
Each operation adds 1 to the rectangle spanning from the bottom-left corner to (r,c); find the number of cells that end up holding the maximum value.
Input
The first line contains q (1≤q≤100000), followed by q lines, each with positive integers r and c (≤10^9).
Output
Output the number of cells that reach the maximum value (use a 64-bit integer).
Example 1
Input:
3
1 4
2 3
4 1
Output:
1
Example notes
Derive a linear-scan/dynamic-programming solution directly from the problem rules; the examples have been checked case by case against an independently built oracle.
Editorial
Loading solution…