#P7659. Hansel and Gretel's Pizza Selection
Hansel and Gretel's Pizza Selection
Hansel and Gretel's Pizza Selection
Hansel and Gretel have a pizza divided into 8 slices. Each slice has a different number of mushrooms denoted by \(S_1, S_2, \dots, S_8\). Gretel loves mushrooms and wants to select 4 consecutive slices (remembering that the pizza is circular, so slice 1 is adjacent to slice 8) such that the total number of mushrooms is maximized.
Your task is to determine the maximum sum of mushrooms that can be obtained from any 4 consecutive slices.
inputFormat
The input consists of 8 space-separated integers \(S_1, S_2, \dots, S_8\) representing the mushroom counts on each slice.
outputFormat
Output a single integer representing the maximum sum of mushrooms from any 4 consecutive slices.
sample
1 2 3 4 5 6 7 8
26