TLE '16 Contest 2 P2 - Packing Microwaves

View as PDF

Submit solution


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

Author:
Problem type
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 of 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 \le N \le 10^9)

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

The next line of input will contain three space-separated integers, A, B, and C (1 \le A, B, C \le 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

1500
3 1 2
20 30 10

Sample Output 1

2

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

1500
30 10 20
5 5 5

Sample Output 2

SCAMMED

Explanation for Sample Output 2

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


Comments


  • 6
    TheCool1James  commented on Oct. 20, 2016, 11:24 p.m.

    The fear of microwaves: Microphobia


    • -5
      IanHu  commented on Dec. 16, 2019, 4:07 a.m.

      This comment is hidden due to too much negative feedback. Show it anyway.