## Mock CCO '18 Contest 4 Problem 5 - Spawn More Overlords

View as PDF

Points: 20 (partial)
Time limit: 0.18s
Memory limit: 64M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Richard has built a very large Zerg army. He has different types of units in his army, specifically he has units that each provide units of supply.

Due to a supply crunch, he must give away some of his units. He wishes to free up exactly units of supply. He can do this by sacrificing some of his existing units and spawning other units. He wants to minimize the sum of number of units he has to sacrifice and number of units he has to spawn. Help him!

All are unique.

#### Input Specification

The first line will contain two space-separated integers, and .

The next line contains space-separated integers, the values in order.

The next line contains space-separated integers, the values in order.

#### Output Specification

Output the minimum desired sum. Output -1 if it's impossible to lose exactly units of supply.

#### Sample Input

3 70
5 25 50
5 2 1

#### Sample Output

3