#P9579. 「Cfz Round 1」Elevator
「Cfz Round 1」Elevator
Background
An elevator is a space that gives people plenty of time to think.
Problem Description
Given two arrays of length . We say a sequence is valid. Let the length of be . The sequence is valid if and only if:
- .
- For all , we have .
- For all , there exists an ordered pair such that , , and .
You need to output, among all valid sequences , the minimum possible length of .
Input Format
The first line contains an integer .
The next lines each contain two integers .
Output Format
Output one integer, the minimum length of among all valid sequences .
2
3 2
2 5
7
4
4 7
10 8
9 11
4 2
18
Hint
[Sample Explanation #1]
The minimum length of is . One such sequence is .
[Constraints]
For all testdata, , , and it is guaranteed that .
This problem uses bundled testdata.
| Subtask ID | Points | Special Property | |
|---|---|---|---|
| None | |||
| Guaranteed | |||
| are generated uniformly at random in | |||
| None | |||
Translated by ChatGPT 5