Wet clothes

4

3 votes
, Algorithms, Algorithms, Very-Easy, Searching algorithm, Linear Search, Linear search
Problem

We have m completely wet clothes out under sunshine waiting to become dry. we are now at second t1 and it's raining. It's going to rain again on seconds t2tn and after each rain clothes will be completely wet again. Cloth number i needs ai seconds to become dry. We can go out and collect all dry clothes at any moment but can't do this more than g times. What is the maximum number of clothes we can collect until second tn? Note that the duration of each rain is almost zero, so we can ignore it. Also collecting clothes does not take any time from us.

Input format

First line of input contains three integers n,m,g (2n100, 1m,g100) respectively. In the second line will be n increasing numbers denoting t1tn (0t1<...<tn104). In the Last line will have m numbers denoting a1am (1ai10000).

Output format

In a single line print maxmimum number of clothes we can collect.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

In the sample, first we go outside at time 5(exactly before rain) and take second piece of clothes. Then for the second time, at second 8, we go and take third piece.

Editor Image

?