Study Schedule Planning
InterviewTime limit1sMemory limit1024 MB
Assign non-negative study hours to N subjects, with a total of at most T, to maximize the summed scores minus the fatigue penalty for the total hours.
- Level
Medium5 of 10
- Topics
- Dynamic programming, Array
- Solved
- No attempts yet
Problem
Banana, a stage performer, has entered her third year of high school. She wants to attend a prestigious university, but she has spent all her time on acting practice and has never studied for school exams. She decides to get serious and study for the college entrance exam that is hours away. Having no study experience, Banana does not know how many hours she should study. Let's make a study schedule for her!
The college entrance exam has subjects. Let be the score Banana earns for subject when she studies it for a total of hours. Following the habits Banana has kept so far, the study time for each subject must be a non-negative integer.
However, human stamina is limited, so studying all day is hard. If she studies for a total of hours, she gets tired and her total score decreases by . The total score can become negative.
You must find the maximum score Banana can get when she studies in the best way, and the study plan that achieves it.
Input
The first line contains and , separated by a space.
From the second line through the -th line, the -th line contains numbers , separated by spaces. These are the scores for subject when studied for hours.
The -th line contains numbers , separated by spaces.
All numbers in the input are integers.
Output
On the first line, print the maximum score Banana can get.
On the second line, print integers separated by spaces, where is the number of hours to study subject . If several study plans give the maximum score, you may print any of them.
Constraints
- ;
- ;