AmazonOA #209
Compute Maximum Scheduled Tasks
估计中等可在线判题
There are n mandatory tasks and n optional tasks, and each task can be done at most once. Each day exactly one mandatory task is scheduled, plus at most one optional task, and their total duration must not exceed H. Find the maximum number of optional tasks completed in n days.
输入格式
The first line contains n H, the second line the mandatory durations, and the third line the optional durations. 1≤n,H≤200000; all durations are in 1..H.
输出格式
Output a single integer, the answer.
样例 1
输入:
4 7
4 5 2 4
5 6 3 4
输出:
2
样例 2
输入:
2 2
1 1
1 1
输出:
2
样例 3
输入:
1 3
3
1
输出:
0
样例说明
The answers are 2, 2 and 0; a total exactly equal to the daily limit can be scheduled.