<p>You are given two integer arrays <code>energyDrinkA</code> and <code>energyDrinkB</code> of the same length <code>n</code> by a futuristic sports scientist. These arrays represent the energy boosts per hour provided by two different energy drinks, A and B, respectively.</p>

<p>You want to <em>maximize</em> your total energy boost by drinking one energy drink <em>per hour</em>. However, if you want to switch from consuming one energy drink to the other, you need to wait for <em>one hour</em> to cleanse your system (meaning you won&#39;t get any energy boost in that hour).</p>

<p>Return the <strong>maximum</strong> total energy boost you can gain in the next <code>n</code> hours.</p>

<p><strong>Note</strong> that you can start consuming <em>either</em> of the two energy drinks.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> energyDrinkA<span class="example-io"> = [1,3,1], </span>energyDrinkB<span class="example-io"> = [3,1,1]</span></p>

<p><strong>Output:</strong> <span class="example-io">5</span></p>

<p><strong>Explanation:</strong></p>

<p>To gain an energy boost of 5, drink only the energy drink A (or only B).</p>
</div>

<p><strong class="example">Example 2:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> energyDrinkA<span class="example-io"> = [4,1,1], </span>energyDrinkB<span class="example-io"> = [1,1,3]</span></p>

<p><strong>Output:</strong> <span class="example-io">7</span></p>

<p><strong>Explanation:</strong></p>

<p>To gain an energy boost of 7:</p>

<ul>
	<li>Drink the energy drink A for the first hour.</li>
	<li>Switch to the energy drink B and we lose the energy boost of the second hour.</li>
	<li>Gain the energy boost of the drink B in the third hour.</li>
</ul>
</div>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>n == energyDrinkA.length == energyDrinkB.length</code></li>
	<li><code>3 &lt;= n &lt;= 10<sup>5</sup></code></li>
	<li><code>1 &lt;= energyDrinkA[i], energyDrinkB[i] &lt;= 10<sup>5</sup></code></li>
</ul>

class Solution:
    def maxEnergyBoost(self, A: List[int], B: List[int]) -> int:
        """
        [4,1,1]
        [1,1,3]


        4,0 
        4,1
        1,0
        1,1


        4,0 ; 1,1
        4,1 ; 1,0


        [411]
        [153]

        all 1, all 2, or first and last of each 

        4112
        0029

        [3,5,6]
        [5,3,5]
        o = 13, e = 14

        [3,5,3,6]
        [4,3,5,4]
        o = 16, e = 17

        [3,5,3,5,9] 25
        [4,3,5,4,8] 24

        for i, max if we choose it and max if we do not





        [4,1,1]
        [1,1,3]

        4,0 
        4,1
        1,0
        1,1

        4,0 ; 1,1
        4,1 ; 1,0

        5
        4
        """

        maxA = A[0]
        maxB = B[0]

        for i in range(1, len(A)):
            newMaxA = max(maxB, maxA + A[i])
            newMaxB = max(maxA, maxB + B[i])
            # print(f"A: {maxB}, {maxA} + {A[i]}")
            # print(f"B: {maxA}, {maxB} + {B[i]}")
            maxA = newMaxA
            maxB = newMaxB
            # print(newMaxA, newMaxB)

        return max(maxA, maxB)



        # o1 = sum(A[0:4])
        # o2 = sum(B[0:4])
        # o3 = A[0] + sum(B[2:4])
        # o4 = B[0] + sum(A[2:4])

        # if A[0] + A[1] + A[2] + A[]
        # b = B[0] + B[1] + B[2]


        # if a > b:
        #     mode = "A"
        #     score = A[0]
        # else:
        #     mode = "B"
        #     score = B[0]

        # for i in range(1, len(A) - 2):
        #     if mode == "A":
        #         a = A[i] + A[i + 1] + A[i + 2]
        #         b = B[i + 1] + B[i + 2]
        #         if a > b:
        #             score += A[i]
        #         else:
        #             mode = "B"
        #     else:
        #         a = A[i + 1] + A[i + 2]
        #         b = B[i] + B[i + 1] + B[i + 2]
        #         if b > a:
        #             score += B[i]
        #         else:
        #             mode = "A"

        # if mode == "A":
        #     a = A[-2] + A[-1]
        #     b = B[-1]
        #     if a > b:
        #         score += a
        #     else:
        #         score += b
        # else:
        #     a = A[-1]
        #     b = B[-2] + B[-1]
        #     if b > a:
        #         score += b
        #     else:
        #         score += a

        # return score


        
1392