# TopCoder

Caido
$\mathbb{W}\mathcal{aimai}\sim$

63.6% (28/44)

23.6% (39/165)

# Input Format

• $3\leq n\leq 10^ 5$
• $1\leq a_i,b_i\leq 10^ {18}$（$0\leq i<n$）
• $b_i\leq b_{i+1}$（$0\leq i\leq n-2$）

3
20 10 30
1 3 15

23

# Sample Input 2

10
395 846 120 567 719 523 162 99 48 311
74 85 241 322 341 415 421 595 705 720

440

# Hints

$x\text{ mod }y$ 代表 $x$ 對 $y$ 取模，也就是 $x$ 除以 $y$ 的餘數

# Problem Source

No. Testdata Range Constraints Score
1 0~1 範例測資 0
2 0~13, 38~39 $n\leq 10^ 3$ 22
3 5~10, 17~22, 29~34 $a_i\leq a_{i+1}$（$0\leq i\leq n-2$） 20
4 0~43 無其他限制 58

# Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 131072 65536 1 2 4
1 1000 131072 65536 1 2 4
2 1000 131072 65536 2 4
3 1000 131072 65536 2 4
4 1000 131072 65536 2 4
5 1000 131072 65536 2 3 4
6 1000 131072 65536 2 3 4
7 1000 131072 65536 2 3 4
8 1000 131072 65536 2 3 4
9 1000 131072 65536 2 3 4
10 1000 131072 65536 2 3 4
11 1000 131072 65536 2 4
12 1000 131072 65536 2 4
13 1000 131072 65536 2 4
14 1000 131072 65536 4
15 1000 131072 65536 4
16 1000 131072 65536 4
17 1000 131072 65536 3 4
18 1000 131072 65536 3 4
19 1000 131072 65536 3 4
20 1000 131072 65536 3 4
21 1000 131072 65536 3 4
22 1000 131072 65536 3 4
23 1000 131072 65536 4
24 1000 131072 65536 4
25 1000 131072 65536 4
26 1000 131072 65536 4
27 1000 131072 65536 4
28 1000 131072 65536 4
29 1000 131072 65536 3 4
30 1000 131072 65536 3 4
31 1000 131072 65536 3 4
32 1000 131072 65536 3 4
33 1000 131072 65536 3 4
34 1000 131072 65536 3 4
35 1000 131072 65536 4
36 1000 131072 65536 4
37 1000 131072 65536 4
38 1000 131072 65536 2 4
39 1000 131072 65536 2 4
40 1000 131072 65536 4
41 1000 131072 65536 4
42 1000 131072 65536 4
43 1000 131072 65536 4