Cargo Ship
Time limit1sMemory limit1024 MB
Given a deck of a by b meters and cars of c by d meters, decide whether all n cars fit, and if not, find the maximum that do.
- Level
Easy2 of 10
- Topics
- Implementation, Math
- Solved
- No attempts yet
Problem
Kostas is the captain of a cargo ship that carries cars across the sea. The ship's cargo deck is a rectangle a meters long and b meters wide. On each trip, the captain carries cars of only one brand, and all of those cars have the same width and the same length.
A customer asked Kostas to ship n cars, each c meters long and d meters wide.
Help Kostas determine whether all the cars fit on the ship. Cars are loaded in rows. All rows must run either along the length of the deck or across its width, not a mix of both. Within a row, all cars face the same direction.
Input
The first line contains two integers a, the length of the cargo deck, and b, the width of the deck.
The second line contains two integers c, the length of one car, and d, the width of one car.
The third line contains one integer, the number of cars to ship.
Output
If all the cars fit on the ship, print TAIP. Otherwise, print the maximum number of cars that can fit on the ship.
Constraints
1 ≤ a, b, c, d ≤ 1000
n ≤ 100 000