AmazonOA #111
Cinema Shows
估计困难可在线判题
Choose some screenings, where a screening ends at start+duration. Two screenings do not conflict only if one ends strictly before the other starts; equal endpoints are not allowed. Find the maximum total audience. The source's second example confirms the strict inequality.
输入格式
The first line contains n (1..100000), followed by three lines start, duration and volume; the first two are in 1..10⁹, and volume is in 1..1000.
输出格式
Output a single integer answer.
样例 1
输入:
5
10 5 15 18 30
20 12 20 35 35
50 51 20 25 10
输出:
76
样例 2
输入:
3
1 2 4
2 2 1
1 2 3
输出:
4
样例 3
输入:
2
1 3
2 1
5 7
输出:
7
样例说明
Example 1: choose the two screenings starting at 5 and 18, 51+25=76. Example 2: the screening starting at 2 ends at 4, so it cannot be followed by the screening starting at 4; choose the ones starting at 1 and 4, for a total of 4. Example 3: the first screening ends exactly when the second starts, so only the screening with audience 7 can be chosen.