QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 1024 MB 總分: 100

#6250. Algorithm Design Class

统计

Bahram and Mohsen, who had decided to co-teach an algorithm design class, have recently encountered a fundamental problem and are set to part ways. The root of the problem is Mohsen's irrational approach to identifying a student's talent in algorithm design. Bahram correctly believes that a student's talent in algorithm design is directly related to their aptitude in discrete mathematics. However, Mohsen claims that a student who understands continuous mathematics better will be a better algorithm designer. Consequently, it was decided that the students in the class would be divided into two groups, with each person taking charge of one group. The division of class members is such that each person, in their turn, selects one student and then passes the turn to the other. This process continues until all students are selected. Since Bahram has a chivalrous nature and has counted on Mohsen's naivety, he allows Mohsen to make the first selection. The irrational Mohsen uses a malicious strategy: each time, he selects the student with the highest aptitude in continuous mathematics from the remaining students. If there are multiple students with this condition, Mohsen chooses one of them at his own discretion. Due to his deep understanding of Mohsen, Bahram has guessed his malicious nature and wants to know what the maximum possible value for the sum of the discrete mathematics aptitudes of the students he selects is, independent of Mohsen's moves. Help Bahram by calculating this value.

Input

The first line of the input contains the integer $n$, representing the number of students. Each of the second and third lines contains $n$ integers, $a_1, a_2, \dots, a_n$ and $b_1, b_2, \dots, b_n$ respectively, where $a_i$ represents the aptitude of student $i$ in continuous mathematics and $b_i$ represents the aptitude of student $i$ in discrete mathematics.

Output

Print the maximum possible value for the sum of the discrete mathematics aptitudes of the students selected by Bahram, assuming Mohsen's strategy is malicious.

Constraints

  • $1 \le n \le 10^5$
  • $1 \le a_i, b_i \le 10^9$

Examples

Input 1

3
1 8 4
12 11 1

Output 1

12

Input 2

5
1 2 3 4 5
2 3 4 5 6

Output 2

8

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.