You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: b.go
    path of file: ./repos/codeforces-go/leetcode/weekly/260/b
    
    the code of the file until where you have to start completion: package main

import "math"

// github.com/EndlessCheng/codeforces-go
func gridGame(grid [][]int) int64 {
	ans := math.MaxInt64
	left0 := 0
	for _, v := range grid[0] {
		l
    
func gridGame(grid [][]int) int64 {
	ans := math.MaxInt64
	left0 := 0
	for _, v := range grid[0] {
		left0 += v
	}
	left1 := 0
	for j, v := range grid[0] { // 枚举第一个机器人在哪拐弯
		left0 -= v
		ans = min(ans, max(left0, left1)) // 第二个机器人只能取上下剩余部分中的最大值
		left1 += grid[1][j]
	}
	return int64(ans)
}