D. [R40D]Yet another ICPC problem

    Type: Default 1000ms 512MiB

[R40D]Yet another ICPC problem

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

时空限制

1s/512M

题目描述

apiadujiangly 要去组队 AK ICPC 了!

ICPC 共有 nn 道题,第 ii 题对于 apiadujiangly 的难度分别为 aia_ibib_iapiadujiangly 都有一个疲劳值,疲劳值初始为 00,一个人每做一道题疲劳值就会加 11。当 apiadu 的疲劳值为 xx 时他解决第 ii 题需要 ai+cxa_i+c_x 秒,当 jiangly 的疲劳值为 yy 时他解决第 jj 题需要 bj+dyb_j+d_y 秒。

每个时刻只能有一个人写题(因为只有一个机位),问他们 AK ICPC 至少需要多少秒?

输入格式

第一行包含一个正整数 nn,表示题目数量。

接下来一行包含 nn 个正整数 a1,a2,,ana_1,a_2,\dots,a_n,具体含义见题目描述。

接下来一行包含 nn 个正整数 b1,b2,,bnb_1,b_2,\dots,b_n。具体含义见题目描述。

接下来一行包含 nn 个正整数 c0,c1,,cn1c_0,c_1,\dots,c_{n-1}。具体含义见题目描述。

最后一行包含 nn 个正整数 d0,d1,,dn1d_0,d_1,\dots,d_{n-1}。具体含义见题目描述。

样例

样例输入 #1

3
1 3 5
6 4 2
1 2 3
1 2 3

样例输出 #1

10

样例解释 #1

这是样例 11 的一种方案:

  • 先由 apiadu 解决问题 11,需要 a1+c0=2a_1+c_0=2 秒。
  • 再由 apiadu 解决问题 22,需要 a2+c1=5a_2+c_1=5 秒。
  • 最后由 jiangly 解决问题 33,需要 b3+d0=3b_3+d_0=3 秒。

总用时 1010 秒,可以证明不存在耗时更少的方案。

样例输入 #2

5
2 4 3 1 2
9 2 5 3 8
1 2 8 3 2
5 4 3 2 1

样例输出 #2

28

数据规模

注意:你只有通过了子任务的所有测试点,才能获得对应子任务的分数。

子任务编号 分数 nn \le ai,bi,cj,dja_i,b_i,c_j,d_j \le
11 4040 1616 100100
22 4040 30003000 10001000
33 2020 2×1052\times 10^5 10910^9

对于 100%100\% 的数据,1n2×1051 \le n \le 2\times 10^51ai,bi,cj,dj1091 \le a_i,b_i,c_j,d_j \le 10^9

代码源挑战赛 Round 40

Not Attended
Status
Done
Rule
DMY
Start at
2025-12-5 20:00
End at
2025-12-5 21:30
Duration
1.5 hour(s)
Host
Partic.
443