Submission #3368361


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][];//ターン数と、左から取った個数の時の、先手の最高得点
    for(long i = 0; i <= a; i++)
    {
      dp[i] = new long[a+1];
    }
    
    for(long turn = 0; turn <= a+b; turn++)
    {
      for(long ll = 0; ll <= a; ll++)
      {
        if(turn % 2 == 1)//先手の番
        {
            if(turn > 0) dp[turn][ll] = 0;
            if(ll-1 >= 0) dp[turn][ll] = Math.Max(dp[turn-1][ll-1] + numsL[ll-1], dp[turn][ll]);
            if(turn-ll >= 0) dp[turn][ll] = Math.Max(dp[turn][ll], dp[turn-1][ll] + numsR[turn-ll]);
        }else//後手の番
        {
          if(turn > 0) dp[turn][ll] = 0;
          if(ll-1 >= 0) dp[turn][ll] = Math.Min(dp[turn-1][ll-1], dp[turn][ll]);
          if(turn-ll >= 0) dp[turn][ll] = Math.Min(dp[turn][ll], dp[turn-1][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 1386 Byte
Status RE
Exec Time 24 ms
Memory 22364 KB

Judge Result

Set Name All
Score / Max Score 0 / 3
Status
RE × 5
Set Name Test Cases
All 00, 01, 02, 90, 91
Case Name Status Exec Time Memory
00 RE 20 ms 12768 KB
01 RE 24 ms 22364 KB
02 RE 24 ms 16864 KB
90 RE 20 ms 10720 KB
91 RE 20 ms 10720 KB