結果

問題 No.1231 Make a Multiple of Ten
ユーザー keymoonkeymoon
提出日時 2021-01-18 12:24:18
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,257 bytes
コンパイル時間 1,875 ms
コンパイル使用メモリ 107,704 KB
実行使用メモリ 48,608 KB
最終ジャッジ日時 2023-08-20 19:43:11
合計ジャッジ時間 5,818 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 59 ms
23,972 KB
testcase_02 WA -
testcase_03 AC 58 ms
19,712 KB
testcase_04 AC 104 ms
34,448 KB
testcase_05 AC 94 ms
28,284 KB
testcase_06 AC 76 ms
24,156 KB
testcase_07 AC 101 ms
32,516 KB
testcase_08 AC 80 ms
25,212 KB
testcase_09 AC 71 ms
25,180 KB
testcase_10 AC 98 ms
34,060 KB
testcase_11 AC 112 ms
41,228 KB
testcase_12 AC 149 ms
45,596 KB
testcase_13 AC 151 ms
46,572 KB
testcase_14 WA -
testcase_15 AC 151 ms
48,608 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;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
        int[][] steps = Enumerable.Repeat(0, 10).Select(_ => Enumerable.Repeat(int.MaxValue / 2, 10).ToArray()).ToArray();
        foreach (var group in a.GroupBy(x => x % 10))
        {
            var key = group.Key;
            var count = group.Count();
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j <= Min(10, count); j++)
                {
                    var nxt = (i + j * key) % 10;
                    steps[i][nxt] = Min(steps[i][nxt], j);
                }
            }
        }
        for (int i = 0; i < 10; i++)
            for (int j = 0; j < 10; j++)
                for (int k = 0; k < 10; k++)
                    steps[j][k] = Min(steps[j][k], steps[j][i] + steps[i][k]);
        Console.WriteLine(n - steps[a.Sum() % 10][0]);
    }
}
0