Problem Statement
- 3 or fewer small packs
- 2 or fewer large packs
- a person and 2 or fewer small packs
- a person and 1 large pack
Definition
- Class:
- Packhorses
- Method:
- horses
- Parameters:
- int, int, int
- Returns:
- int
- Method signature:
- int horses(int p, int x, int y)
- (be sure your method is public)
Constraints
- p will be between 1 and 1000 inclusive.
- x and y will be between 0 and 1000 inclusive.
Examples
1
5
0
Returns: 2
One horse can carry the person and two small packs, and the other can carry the remaining three small packs.
1
6
0
Returns: 3
One way to get 3 horses to carry this load is to have each horse take two small packs, with one of the horses also carrying the person.
20
15
7
Returns: 20
5
1
5
Returns: 6
5
5
18
Returns: 13
1
3
1
Returns: 2
1
0
0
Returns: 1
1
1000
1000
Returns: 834
1
998
1000
Returns: 833
1000
1000
1000
Returns: 1250
498
1000
1000
Returns: 1000
497
1000
1000
Returns: 999
300
1
932
Returns: 617
300
0
932
Returns: 616
30
3
722
Returns: 377
30
3
723
Returns: 378
30
3
724
Returns: 378
1000
1000
1000
Returns: 1250
2
3
0
Returns: 2
100
222
333
Returns: 274
1
9
1
Returns: 4
2
5
1
Returns: 3
1
2
2
Returns: 2
2
4
2
Returns: 3
969
1000
999
Returns: 1234
1
1
2
Returns: 2
2
5
3
Returns: 4
1
30
0
Returns: 11
20
153
137
Returns: 127
20
13
19
Returns: 23
5
6
5
Returns: 7
1
3
7
Returns: 5
30
60
50
Returns: 55
1
5
2
Returns: 3
20
80
21
Returns: 44
5
10
4
Returns: 7
500
1000
5
Returns: 503