Submission #3369623
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+1][];//左からll個、右からrr個取った時の、先手の最高得点。[a,b]=0 for(long i = 0; i <= a; i++) { dp[i] = new long[b+1]; } for(long ll = a; ll >= 0; ll--) { for(long rr = b; rr >= 0; rr--) { if(ll == a && rr == b) continue; if((ll + rr) % 2 == 0)//先手の番 { if(ll == a) dp[ll][rr] = dp[ll][rr+1] + numsR[rr]; else if(rr == b) dp[ll][rr] = dp[ll+1][rr] + numsL[ll]; else dp[ll][rr] = Math.Max(dp[ll+1][rr] + numsL[ll], dp[ll][rr+1]+numsR[rr]); //Console.WriteLine(ll+" "+rr+" "+dp[ll][rr]); }else//後手の番 { if(ll == a) dp[ll][rr] = dp[ll][rr+1]; else if(rr == b) dp[ll][rr] = dp[ll+1][rr]; else dp[ll][rr] = Math.Min(dp[ll+1][rr], dp[ll][rr+1]); //Console.WriteLine(ll+" "+rr+" "+dp[ll][rr]); } } } Console.WriteLine(dp[0][0]); } }
Submission Info
Submission Time | |
---|---|
Task | B - ゲーム |
User | suikameron |
Language | C# (Mono 4.6.2.0) |
Score | 3 |
Code Size | 1481 Byte |
Status | AC |
Exec Time | 31 ms |
Memory | 19168 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 3 / 3 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | 00, 01, 02, 90, 91 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00 | AC | 21 ms | 11220 KB |
01 | AC | 28 ms | 17960 KB |
02 | AC | 31 ms | 19168 KB |
90 | AC | 20 ms | 9172 KB |
91 | AC | 20 ms | 9172 KB |