Submission #3369338
Source Code Expand
using System; using System.Linq;//リストの使用 using System.Collections.Generic; class Program { static void Main() { string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。 long a = long.Parse(input[0]); long b = long.Parse(input[1]); long[] numsL = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse); long[] numsR = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse); long[][] dp = new long[a+b+1][a+1];//残り個数と、左に残っている個数の時の、先手の最高得点。[a+b,a]=0 for(long i = 0; i <= a+b; i++) { dp[i] = new long[a+1]; } for(long turn = 1; turn <= a+b; turn++) { for(long ll = 0; ll <= a; ll++) { if((a + b - turn) % 2 == 1)//先手の番 { if(turn>=1 && ll>=1 && turn-ll>=1) dp[turn][ll] = Math.Max(dp[turn-1][ll-1] + numsL[ll-1], dp[turn-1][ll] + numsR[turn-ll-1]); if(turn>=1 && ll>=1) dp[turn][ll] = dp[turn-1][ll-1] + numsL[ll-1]; if(turn>=1 && turn-ll>=1) dp[turn][ll] = dp[turn-1][ll] + numsR[turn-ll-1]; Console.WriteLine(turn+" "+ll+" "+dp[turn][ll]); }else//後手の番 { if(turn>=1 && ll>=1 && turn-ll>=1) dp[turn][ll] = Math.Min(dp[turn-1][ll-1], dp[turn-1][ll]); if(turn>=1 && ll>=1) dp[turn][ll] = dp[turn-1][ll-1]; if(turn>=1 && turn-ll>=1) dp[turn][ll] = dp[turn-1][ll]; Console.WriteLine(turn+" "+ll+" "+dp[turn][ll]); } } } Console.WriteLine(dp[a+b][a]); } }
Submission Info
Submission Time | |
---|---|
Task | B - ゲーム |
User | suikameron |
Language | C# (Mono 4.6.2.0) |
Score | 0 |
Code Size | 1641 Byte |
Status | CE |
Compile Error
./Main.cs(13,32): error CS0029: Cannot implicitly convert type `long' to `long[][]'