Climbing Taihang Mountains in Snow
题号:NC316710
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

A mountain-climbing camp on the Taihang Mountains offers visitors two kinds of activities: a leisure sightseeing route and a challenging climbing route. The camp sets a fitness threshold: when a person's fitness value is strictly greater than this threshold, they will choose the challenging climb; otherwise, they will choose the leisure sightseeing route.

There are currently n people. For the i-th person, their fitness value is h_i. If they take the leisure sightseeing route, their satisfaction value is a_i; if they take the challenging climbing route, their satisfaction value is b_i. Before the activities begin, you may reset this fitness threshold so that the total satisfaction value of these n people is maximized. You only need to find this maximum possible value.

Note: the fitness threshold can be set to 0, in which case everyone will take the challenging climbing route; it can also be set to infinity, in which case everyone will take the leisure sightseeing route.

输入描述:

The first line contains a positive integer n (1 \le n \le 2 \times 10^5).

The second line contains n positive integers h_1, h_2, \ldots, h_n (1\le h_i\le 10^9). It is guaranteed that all h_i are pairwise distinct.

The third line contains n positive integers a_1, a_2, \ldots, a_n (1\le a_i\le 10^9).

The fourth line contains n positive integers b_1, b_2, \ldots, b_n (1\le b_i\le 10^9).

输出描述:

Output one line containing a positive integer, denoting the maximum possible total satisfaction value.
示例1

输入

复制
5
163 145 188 150 176
1 2 3 4 5
5 4 3 2 1

输出

复制
15

说明

One possible plan is to set the fitness threshold to 180. Then visitors 1, 2, 4, and 5 will all take the leisure sightseeing route, with total satisfaction 1+2+4+5=12; visitor 3 will take the challenging climbing route, with satisfaction 3. The total satisfaction is 15. There is no better plan.