logo AlgoBeat OnlineJudge
登录 注册

#213645. [OOI 2024] Three Arrays

内存限制:512 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

You are given three arrays , , and of length , with elements indexed from , as well as the integers and . You construct two arrays and of length according to the following rules:

  • ,
  • For all from to , perform the following actions:
    • Set the elements as and .
    • Choose exactly of the following operations and apply it:

You want to construct arrays and to maximize the value of . Find the maximum value of that can be obtained by performing the described actions.

输入格式

The first line contains a single integer () --- the length of arrays , , and .

The second line contains integers () --- the array .

The third line contains integers () --- the array .

The fourth line contains integers () --- the array .

The fifth line contains two integers and ().

输出格式

Output a single integer --- the maximum possible value of among all possible ways to construct arrays and .

样例

样例输入 1

5
4 0 7 0 8
10 5 3 7 7
8 5 9 2 23
4 8

样例输出 1

34

数据范围与提示

Note

In the first set of input data, the following sequence of actions leads to the maximum answer:

  • , .
  • , .
  • The minimum is applied to , the value of remains the same.
  • , .
  • The minimum is applied to , the value of remains the same.
  • , .
  • The minimum is applied to , the value of remains the same.
  • , .
  • The minimum is applied to , the value of remains the same.
  • , .
  • The value of remains the same, .
  • .

It can be shown that this is the maximum value.

Scoring

The tests for this problem consist of six groups. Points for each group are given only if all tests of the group and all tests of the required groups are passed. Please note that passing the example tests is not required for some groups. means that the results of testing your solution on this group will only be available after the end of the competition.

Group Points Additional constraints < Required groups Comment
0 -- -- -- Examples.
1 13 0
2 18 0, 1
3 14 --
4 16 -- 0--3
5 19 -- 3
6 20 -- 0--5 Offline-evaluation.