Problem G
Island Farming
After a “disagreement” with the captain of your pirate crew,
you have been marooned on a barren, deserted island.
Unbeknownst to them, there was a hidden cache of
By planting coconuts, you could get enough wood to build a boat and stockpile enough food to take you off the island!
You must meet 2 requirements before you feel comfortable enough to leave the island:
-
A boat, which requires wood from
fully-grown coconut trees. -
coconuts to eat on the journey.
The island does not start out with any coconut trees, so you must plant them.
Each day, due to the very rocky ground, you can choose to
plant up to one coconut. A coconut tree takes
Immature coconut trees do not produce coconuts, and you cannot use them to build your boat. (However, you can build the entire boat on the day that you wish to leave).
Starting from today as day
Explanation of Sample Input 1
You start with
On both day
Since you have
Input
The only line of input contains four integers
Output
The soonest day that you can leave the island with a boat
built from
Sample Input 1 | Sample Output 1 |
---|---|
5 2 6 2 |
3 |