#P15800. [GESP202603 六级] 选数
[GESP202603 六级] 选数
Background
Related multiple-choice and true/false questions: https://ti.luogu.com.cn/problemset/1210.
Problem Description
Given two arrays and , each containing integers. You need to choose some indices () such that the following conditions are satisfied:
- ().
- ().
Under these conditions, you need to maximize , i.e., maximize the sum of the values in array at the chosen indices.
Input Format
The first line contains a positive integer , indicating the array length.
The second line contains positive integers , representing array .
The third line contains positive integers , representing array .
Output Format
One line containing an integer, representing the maximum possible sum of the values in array at the chosen indices, under the index constraints.
4
1 2 3 4
3 3 1 1
7
6
1 1 4 5 1 4
1 2 3 2 1 0
11
Hint
For of the testdata, it is guaranteed that .
For all testdata, it is guaranteed that , , and .
Translated by ChatGPT 5