結果

問題 No.1231 Make a Multiple of Ten
ユーザー semisagisemisagi
提出日時 2020-09-18 21:33:09
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 1,532 bytes
コンパイル時間 4,022 ms
コンパイル使用メモリ 103,120 KB
実行使用メモリ 46,484 KB
最終ジャッジ日時 2023-09-05 18:10:07
合計ジャッジ時間 6,770 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
20,656 KB
testcase_01 AC 60 ms
22,648 KB
testcase_02 AC 57 ms
20,620 KB
testcase_03 AC 60 ms
22,728 KB
testcase_04 AC 119 ms
35,868 KB
testcase_05 AC 113 ms
34,728 KB
testcase_06 AC 82 ms
26,184 KB
testcase_07 AC 124 ms
34,124 KB
testcase_08 AC 94 ms
30,160 KB
testcase_09 AC 76 ms
26,124 KB
testcase_10 AC 116 ms
33,060 KB
testcase_11 AC 123 ms
36,820 KB
testcase_12 AC 174 ms
43,352 KB
testcase_13 AC 181 ms
44,344 KB
testcase_14 AC 59 ms
20,728 KB
testcase_15 AC 181 ms
46,484 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3 {
    class Program {
        static void Main(string[] args) {
            var scanner = new Scanner();
            int N = scanner.NextInt();
            int[] A = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = scanner.NextInt();
            }
            int[] dp = new int[10];
            for (int i = 0; i < 10; i++) {
                dp[i] = int.MinValue;
            }
            dp[0] = 0;
            foreach (int x in A) {
                int[] to = new int[10];
                for (int i = 0; i < 10; i++) {
                    to[i] = dp[i];
                }
                for (int i = 0; i < 10; i++) {
                    to[(i + x) % 10] = Math.Max(to[(i + x) % 10], dp[i] + 1);
                }
                dp = to;
            }
            Console.WriteLine(dp[0]);
        }
    }

    class Scanner {
        int index = 0;
        string[] tokens = { };

        public string Next() {
            if (index == tokens.Length) {
                index = 0;
                tokens = Console.ReadLine().Split(' ');
            }
            return tokens[index++];
        }

        public int NextInt() {
            return int.Parse(Next());
        }

        public long NextLong() {
            return long.Parse(Next());
        }

        public double NextDouble() {
            return double.Parse(Next());
        }
    }
}
0