#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 teams, and each team has photos.
For each team that Nikola collects, if the number of photos he has from that team is , he gains points. Currently, the number of photos he has from team is .
Nikola’s good friend Ivan has two complete albums. Ivan decides to give Nikola photos. Nikola wants to know the maximum total score his album can achieve after receiving these photos.
Input Format
The first line contains integers .
The second line contains integers .
The third line contains integers , where means that collecting different photos from a team gives points.
For every integer in , it holds that . Also, .
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 photos from teams , respectively. The best plan is to get photos from team and photo from team . Then the score is maximized, equal to .
Constraints
For of the testdata, .
For of the testdata, , , , .
Notes
The scoring of this problem follows the original COCI problem settings, with a full score of .
This problem is translated from COCI2018-2019 CONTEST #6 T3 Sličice.
Translated by ChatGPT 5