#P11769. 歌唱练习
歌唱练习
Description
Tianyi has made a practice plan spanning days. She works extremely hard, and her daily practice duration must be monotonically non-decreasing. Meanwhile, to protect her voice, she can practice for a maximum of units of time on the -th day. The effectiveness of practice varies from day to day, influenced by factors such as weather, and we quantify the effectiveness of practice on the -th day as , indicating that every unit of time she practices on that day will increase her familiarity by . Note that it is possible for to be less than , meaning that perhaps due to factors like excessive heat, her practice may have a negative impact.
Now, Tianyi has researched the weather forecast for the next days and estimated the values of and for each day. Please determine the maximum amount her familiarity can be improved.
Input Format
The first line of input contains an integer — the number of days in Tianyi's practice plan.
The second line of input contains integers — the maximum units of time Tianyi can spend on practicing on each day.
The third line of input contains integers — the effectiveness of practice on each day.
Output Format
The only line of output contains an integer — the maximum amount her familiarity can be improved.
3
3 2 3
2 -1 1
5
Hint
Sample Explanation
She practices for units of time on the first day,increasing her familarity by ;
She practices for units of time on the second day,increasing her familarity by (decreasing by );
She practices for units of time on the third day,increasing her familarity by .
Tianyi's familiarity has increased by a total of 5.
It can be proved that there is no way to increase her familiarity higher than .
Constraints
Subtasks Applied. You can only gain the score of the subtask if you accepted all the tests in the subtask.
| Subtask ID | Special Property | Score | ||
|---|---|---|---|---|
| No | ||||
| Yes | ||||
| No | ||||
Special Property: is uniformly randomly generated in
For all tests, it is guaranteed that ,,.
京公网安备 11011102002149号