#P3582. [POI 2015 R1] 影迷 Movie-goer
[POI 2015 R1] 影迷 Movie-goer
Description
There are movies, numbered . The -th movie has value .
Over days, exactly one movie is shown per day; on day , movie is shown.
You may choose () and watch all movies shown on days .
However, if you watch the same movie more than once, you get bored and therefore cannot obtain this movie’s value.
Now you need to maximize the total value of the movies that are watched exactly once.
Input Format
The first line contains two integers .
The second line contains integers; the -th is .
The third line contains integers; the -th is .
Output Format
Print one integer, the maximum possible sum of values of movies watched exactly once.
9 4
2 3 1 1 4 1 2 4 1
5 3 6 6
15
Hint
Constraints
For of the testdata, , , and .
Original problem name: Kinoman.
Translated by ChatGPT 5
京公网安备 11011102002149号