All Tracks Algorithms Searching Linear Search Problem

Wet clothes
Tag(s):

Algorithms, Linear search, Searching algorithm, Very-Easy

Problem
Editorial
Analytics

We have $$m$$ completely wet clothes out under sunshine waiting to become dry. we are now at second $$t_1$$ and it's raining. It's going to rain again on seconds $$t_2 \dots t_n$$ and after each rain clothes will be completely wet again. Cloth number $$i$$ needs $$a_i$$ 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 $$t_n$$? 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$$ ($$ 2 \le n \le 100 $$, $$ 1 \le m, g \le 100 $$) respectively. In the second line will be $$n$$ increasing numbers denoting $$t_1 \dots t_n$$ ($$ 0 \le t_1 < ... < t_n \le 10^4 $$). In the Last line will have $$m$$ numbers denoting $$a_1 \dots a_m$$ ($$ 1 \le a_i \le 10000 $$).

Output format

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

SAMPLE INPUT
3 3 2
3 5 8
4 1 3
SAMPLE OUTPUT
2
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.

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

HackerEarth

Challenge Name

March Circuits '19

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications

?