Untitled
unknown
plain_text
a year ago
793 B
12
Indexable
public int harvestTime(int input1, int[] input2, int[] input3, int input4) {
if (input1 == 0) return 0;
int totalTime = input2[0]; // First vegetable's harvest time
int currentTime = totalTime;
// Process remaining vegetables
for (int i = 1; i < input1; i++) {
// Add base harvest time
int timeForCurrent = input2[i];
// Add land switching penalty if land type is different from previous
if (input3[i] != input3[i-1]) {
timeForCurrent += input4;
}
// Add incremental time (position-based penalty)
timeForCurrent += i;
// Update total time
currentTime = currentTime + timeForCurrent;
totalTime = currentTime;
}
return totalTime;
}
Editor is loading...
Leave a Comment