#P7381. [COCI 2018/2019 #6] Sličice

[COCI 2018/2019 #6] Sličice

Problem Description

Nikola likes collecting photos of football players and keeping them in an album. He plans to collect player photos from NN teams, and each team has MM photos.

For each team that Nikola collects, if the number of photos he has from that team is xx, he gains BxB_x points. Currently, the number of photos he has from team ii is PiP_i.

Nikola’s good friend Ivan has two complete albums. Ivan decides to give Nikola KK photos. Nikola wants to know the maximum total score his album can achieve after receiving these KK photos.

Input Format

The first line contains integers N,M,KN, M, K.

The second line contains NN integers PiP_i.

The third line contains M+1M+1 integers BiB_i, where BiB_i means that collecting ii different photos from a team gives BiB_i points.

For every integer tt in [0,M1][0, M-1], it holds that BtBt+1B_t \le B_{t+1}. Also, KN×Mi=1NPiK \le N \times M-\sum_{i=1}^N P_i.

Output Format

Output the maximum total score that can be obtained.

4 4 3
4 2 3 1
0 1 3 6 10
31
4 3 5
1 1 2 3
0 1 2 3
12
3 6 2
2 4 1
31 38 48 60 75 91 120
206

Hint

Sample 1 Explanation

At the beginning, Nikola has 4,2,3,14, 2, 3, 1 photos from teams 1,2,3,41, 2, 3, 4, respectively. The best plan is to get 22 photos from team 22 and 11 photo from team 11. Then the score is maximized, equal to 10+10+10+1=3110+10+10+1=31.

Constraints

For 20%20\% of the testdata, K=2K=2.

For 100%100\% of the testdata, 1N,M5001 \le N, M \le 500, 1Kmin(N×M,500)1 \le K \le \min(N \times M, 500), 0PiM0 \le P_i \le M, 0Bi1050 \le B_i \le 10^5.

Notes

The scoring of this problem follows the original COCI problem settings, with a full score of 9090.

This problem is translated from COCI2018-2019 CONTEST #6 T3 Sličice.

Translated by ChatGPT 5