TopCoder

User's AC Ratio

100.0% (7/7)

Submission's AC Ratio

44.4% (8/18)

Tags

Description

小 Y 經營著一間工廠,該工廠有兩條生產線,兩條生產線都被切成 n 格,分別有各自的能量係數 a1,a2,,anb1,b2,,bn,整間工廠的產能為
i=1naibi.

小 Y 可以反轉第一條生產線 a1,a2,,an 中某個子區間的能量係數 ( 也可以選擇不反轉 ),讓總產能最大化,請幫小 Y 計算最大的產能為多少。

Input Format

輸入的第一行包含一個正整數 n(1n5000)
第二行包含 n 個整數 a1,a2,,an(1ai107)
第三行包含 n 個整數 b1,b2,,bn(1bi107)

Output Format

請輸出一個整數,代表小 Y 工廠的最大產能。

Sample Input 1

5
2 5 1 5 2
1 2 4 2 2

Sample Output 1

38

Sample Input 2

2
22 75
26 45

Sample Output 2

3947

Sample Input 3

10
2 5 6 5 2 1 7 9 7 2
5 5 2 4 7 6 2 2 8 7

Sample Output 3

260

Hints

Problem Source

Codeforces

Subtasks

No. Testdata Range Constraints Score
1 0~2 範例測資 0
2 0~27 無額外限制 100

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 524288 65536 1 2
1 1000 524288 65536 1 2
2 1000 524288 65536 1 2
3 1000 524288 65536 2
4 1000 524288 65536 2
5 1000 524288 65536 2
6 1000 524288 65536 2
7 1000 524288 65536 2
8 1000 524288 65536 2
9 1000 524288 65536 2
10 1000 524288 65536 2
11 1000 524288 65536 2
12 1000 524288 65536 2
13 1000 524288 65536 2
14 1000 524288 65536 2
15 1000 524288 65536 2
16 1000 524288 65536 2
17 1000 524288 65536 2
18 1000 524288 65536 2
19 1000 524288 65536 2
20 1000 524288 65536 2
21 1000 524288 65536 2
22 1000 524288 65536 2
23 1000 524288 65536 2
24 1000 524288 65536 2
25 1000 524288 65536 2
26 1000 524288 65536 2
27 1000 524288 65536 2