func main() var n: int :: cui@inputInt() var p: []int :: #[n]int var a: []int :: #[n]int for i(0, n - 1) do p[i] :: cui@inputInt() do a[i] :: cui@inputInt() end for ; i本目, j = 0 => p本を選んだ。j=1 => a本を選んだ。 var dp: [][]int :: #[n, 2]int do dp[0][0] :: p[0] do dp[0][1] :: a[0] for i(1, n - 1) do dp[i][0] :: [dp[i - 1][0], dp[i - 1][1] + p[i]].max() + p[i] do dp[i][1] :: [dp[i - 1][0], dp[i - 1][1] + a[i]].max() + a[i] end for var ans: int :: dp[n - 1][0] do cui@print("\{ans}\n") end func