TLE '16 Contest 2 P2 - Packing Microwaves

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 256M

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
TT1103 very neatly arranges the microwaves inside of the truck.

TT1103 is delivering a large quantity of identical-sized microwaves to MC (Microwave Central). To make things faster, he has borrowed a truck from his magic grandpa.

A little known fact is that when microwaves enter Microwave Central, they must all be aligned in the same way. Thus, TT1103 must pack all of the microwaves into the truck in the same orientation. In particular, each side of the microwave must be parallel to one side to the truck.

TT1103 has N microwaves to pack, and each microwave is a rectangular prism with dimensions X by Y by Z. The truck he borrowed is a rectangular prism with dimensions A by B by C. Please help TT1103 figure out how many trips he will have to make so he can inform his magic grandpa!

Input Specification

The first line of input will contain a single integer: N (1 \leq N \leq 10^9)

The next line of input will contain three space-separated integers, X, Y, and Z (1 \leq X, Y, Z \leq 10^5), the dimensions of each microwave.

The next line of input will contain three space-separated integers, A, B, and C (1 \leq A, B, C \leq 10^9), the dimensions of the truck.

Output Specification

Output a single integer: the minimal number of trips TT1103 will have to make if he packs the microwaves optimally. If TT1103 cannot fit a single microwave into the truck, print SCAMMED.

Note: It is recommended to use 64-bit integers (long long in C++, int64 in Pascal, long in Java) when computing the answer. It is guaranteed that the maximum number of microwaves that can fit in a truck will fit in a 64-bit signed integer.

Sample Input 1

3 1 2
20 30 10

Sample Output 1


Explanation for Sample Output 1

If TT1103 optimally arranges microwaves, he can fit 1000 microwaves inside of the truck at once. Thus, he can deliver all of the microwaves in 2 trips.

Sample Input 2

30 10 20
5 5 5

Sample Output 2


Explanation for Sample Output 2

TT1103 cannot fit any microwaves into the truck, and thus he has been SCAMMED.


  • 5
    TheCool1James  commented on Oct. 20, 2016, 7:24 p.m.

    The fear of microwaves: Microphobia

    • -1
      IanHu  commented on Dec. 15, 2019, 11:07 p.m.