結果

問題 No.1231 Make a Multiple of Ten
ユーザー masayamatumasayamatu
提出日時 2021-09-04 17:42:06
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 168 ms / 2,000 ms
コード長 1,393 bytes
コンパイル時間 12,758 ms
コンパイル使用メモリ 146,968 KB
実行使用メモリ 197,376 KB
最終ジャッジ日時 2023-08-23 06:44:11
合計ジャッジ時間 16,369 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
28,804 KB
testcase_01 AC 52 ms
28,932 KB
testcase_02 AC 52 ms
28,816 KB
testcase_03 AC 52 ms
28,844 KB
testcase_04 AC 112 ms
47,336 KB
testcase_05 AC 102 ms
45,668 KB
testcase_06 AC 74 ms
36,988 KB
testcase_07 AC 114 ms
48,044 KB
testcase_08 AC 84 ms
39,604 KB
testcase_09 AC 64 ms
32,500 KB
testcase_10 AC 108 ms
46,324 KB
testcase_11 AC 120 ms
51,336 KB
testcase_12 AC 160 ms
63,732 KB
testcase_13 AC 167 ms
65,132 KB
testcase_14 AC 52 ms
28,928 KB
testcase_15 AC 168 ms
197,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  Determining projects to restore...
  Restored /home/judge/data/code/main.csproj (in 130 ms).
.NET 向け Microsoft (R) Build Engine バージョン 17.0.0-preview-21470-01+cb055d28f
Copyright (C) Microsoft Corporation.All rights reserved.

  プレビュー版の .NET を使用しています。https://aka.ms/dotnet-core-preview をご覧ください
  main -> /home/judge/data/code/bin/Release/net6.0/main.dll
  main -> /home/judge/data/code/bin/Release/net6.0/publish/

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace yukicoder
{
    class Program
    {
        const int intMax = 1000000000;
        const long longMax = 2000000000000000000;
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var dp = new long[N + 1, 10];
            var modA = A.Select(p => p % 10).ToArray();
            dp[0, 0] = 0;
            for(int i = 1; i <= N; i++)
            {
                for(int j = 0; j < 10; j++)
                {
                    if((i == 1 && j == 0) || dp[i - 1,j] > 0)
                    {
                        dp[i, (j + modA[i - 1]) % 10] = Math.Max(dp[i - 1, j] + 1, dp[i, (j + modA[i - 1]) % 10]);
                        if(i + 1 <= N)
                        {
                            dp[i + 1, (j + modA[i - 1]) % 10] = Math.Max(dp[i + 1, (j + modA[i - 1]) % 10],dp[i, (j + modA[i - 1]) % 10]);
                        }
                    }
                    if(i + 1 <= N)
                    {
                        dp[i + 1, j] = Math.Max(dp[i + 1,j],dp[i,j]);
                    }             
                    
                }
            }
            Console.WriteLine(dp[N, 0]);
        }
    }
}
0