static int mostGeodes(int ore, int clay, int obsidian, int geode, int oreBot, int clayBot,
int obsidianBot, int geodeBot, int time, int maxTime, int[] botsCost) {
if (time == maxTime) {
return geode;
}
int oreTotal = ore + oreBot;
int clayTotal = clay + clayBot;
int obsidianTotal = obsidian + obsidianBot;
int geodeTotal = geode + geodeBot;
if (ore >= botsCost[4] && obsidian >= botsCost[5]) {
return mostGeodes(oreTotal - botsCost[4], clayTotal, obsidianTotal - botsCost[5],
geodeTotal, oreBot, clayBot, obsidianBot, geodeBot + 1, time + 1, maxTime, botsCost);
}
if (clayBot >= botsCost[3] && obsidianBot < botsCost[5] && ore >= botsCost[2] && clay >= botsCost[3]) {
return mostGeodes(oreTotal - botsCost[2], clayTotal - botsCost[3], obsidianTotal, geodeTotal,
oreBot, clayBot, obsidianBot + 1, geodeBot, time + 1, maxTime, botsCost);
}
int best = 0;
if (obsidianBot < botsCost[5] && ore >= botsCost[2] && clay >= botsCost[3]) {
best = Math.max(best, mostGeodes(oreTotal - botsCost[2], clayTotal - botsCost[3], obsidianTotal,
geodeTotal, oreBot, clayBot, obsidianBot + 1, geodeBot, time + 1, maxTime, botsCost));
}
if (clayBot < botsCost[3] && ore >= botsCost[1]) {
best = Math.max(best, mostGeodes(oreTotal - botsCost[1], clayTotal, obsidianTotal, geodeTotal, oreBot,
clayBot + 1, obsidianBot, geodeBot, time + 1, maxTime, botsCost));
}
if (oreBot < 4 && ore >= botsCost[0]) {
best = Math.max(best, mostGeodes(oreTotal - botsCost[0], clayTotal, obsidianTotal, geodeTotal,
oreBot + 1, clayBot, obsidianBot, geodeBot, time + 1, maxTime, botsCost));
}
if (ore <= 4) {
best = Math.max(best, mostGeodes(oreTotal, clayTotal, obsidianTotal, geodeTotal, oreBot, clayBot, obsidianBot,
geodeBot, time + 1, maxTime, botsCost));
}
return best;
}