cf/mirror

New Year and Ascent Sequence

CF
1284B1400· specialist2s1024 MB⌨ stdin/stdout

Examples

Sample 1of 3
Input
5
1 1
1 1
1 2
1 4
1 3
Output
9
Sample 2of 3
Input
3
4 2 0 2 0
6 9 9 8 8 7 7
1 6
Output
7
Sample 3of 3
Input
10
3 62 24 39
1 17
1 99
1 60
1 64
1 30
2 79 29
2 20 73
2 85 37
1 100
Output
72
1284B.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)