#P9519. pay

pay

Problem Description

Today is payday at Company L.

There are nn employees standing in a line to receive their salaries, numbered from 11 to nn. The ii-th employee has an expected happiness value aia_i.

The boss is very stingy, and among these nn employees, he only chooses mm employees b1,b2,,bmb_1,b_2,\cdots,b_m to pay a salary of kk yuan.

The employees are very empathetic: not only does their happiness increase when they themselves get paid, but it also increases when nearby employees get paid.

Specifically, when an employee at distance dd from employee A gets paid, A's happiness increases by max(0,kd)\max(0, k - d). In particular, if A himself gets paid, A's happiness increases by kk.

The boss hopes that you can find the smallest integer kk such that every employee's happiness is not less than their expectation.

Input Format

The first line contains two integers n,mn,m.

The second line contains nn integers a1,a2,,ana_1,a_2,\cdots,a_n.

The third line contains mm integers b1,b2,,bmb_1,b_2,\cdots,b_m.

Output Format

One integer, representing the smallest kk you found.

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

Hint

Sample Explanation

In sample 11, when k=2k=2, everyone's happiness values are 3,4,4,4,33,4,4,4,3, which meets the requirements.

In sample 22, when k=5k=5, everyone's happiness values are 5,7,7,7,75,7,7,7,7, which meets the requirements.

Constraints

For 10%10\% of the testdata, n=1n=1.

For 30%30\% of the testdata, n300n\le 300.

For 60%60\% of the testdata, n5000n\le 5000.

For another 10%10\% of the testdata, m=1m=1.

For 100%100\% of the testdata, 1mn1061\le m\le n\le 10^6, 0ai1090\le a_i\le 10^9, 1bin1\le b_i\le n, and all bib_i are distinct.

The input size of this problem is large, so please use a proper input method.

Translated by ChatGPT 5