Problem Statement
In order to cook hamburgers, a chef must fry them 5 minutes on each side. However, the two 5 minute intervals do not have to happen consecutively.
panSize indicates how many hamburgers can fit into the given pan, while hamburgers represents the number of hamburgers that need to be fried. Given panSize and hamburgers return the minimum amount of time (in minutes) required to fry all the hamburgers.
Definition
- Class:
- FryingHamburgers
- Method:
- howLong
- Parameters:
- int, int
- Returns:
- int
- Method signature:
- int howLong(int panSize, int hamburgers)
- (be sure your method is public)
Constraints
- panSize is between 1 and 1000 inclusive.
- hamburgers is between 0 and 1000 inclusive.
Examples
2
3
Returns: 15
We will assume that the three hamburgers given are A, B and C. The chef could fry A and B on one side, taking up 5 minutes. Then remove B and fry A on its second side together with C on its first side. After 5 minutes, remove A and fry B and C on their second sides for another 5 minutes. The total time used is 15 minutes.
3
4
Returns: 15
We will assume that the four hamburgers given are A, B, C and D. The chef could fry A, B and C on one side, taking up 5 minutes. Then remove C and fry A and B on their second side together with D on its first side. So after a total of 10 minutes A and B are completely fried, while C and D are fried on one side only. Finally, the chef fries C and D on their second side, taking another 5 minutes. The total time used is 15 minutes.
3
2
Returns: 10
100
0
Returns: 0
There are no hamburgers, so we do not have to fry anything.
3
8
Returns: 30
925
945
Returns: 15
303
919
Returns: 35
493
820
Returns: 20
23
420
Returns: 185
750
597
Returns: 10
11
206
Returns: 190
56
808
Returns: 145
367
734
Returns: 20
1
1
Returns: 10
1
0
Returns: 0
1000
1
Returns: 10
1000
0
Returns: 0
1
1000
Returns: 10000
619
932
Returns: 20
840
312
Returns: 10
525
620
Returns: 15
1000
1000
Returns: 10
999
1000
Returns: 15
566
962
Returns: 20
73
522
Returns: 75
224
410
Returns: 20
500
1000
Returns: 20
160
874
Returns: 55
113
454
Returns: 45
517
805
Returns: 20
20
652
Returns: 330
6
64
Returns: 110
24
716
Returns: 300
475
652
Returns: 15
442
507
Returns: 15
228
508
Returns: 25
499
1000
Returns: 25
501
1000
Returns: 20
501
756
Returns: 20
606
670
Returns: 15
438
629
Returns: 15
2
1
Returns: 10
3
1
Returns: 10
10
1
Returns: 10
4
2
Returns: 10
100
1
Returns: 10
40
1
Returns: 10
5
2
Returns: 10
1
2
Returns: 20
10
0
Returns: 0
6
3
Returns: 10
10
19
Returns: 20
300
17
Returns: 10
5
8
Returns: 20
4
11
Returns: 30
5
1
Returns: 10