結果
問題 | No.1231 Make a Multiple of Ten |
ユーザー |
![]() |
提出日時 | 2021-01-18 12:24:18 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,257 bytes |
コンパイル時間 | 2,330 ms |
コンパイル使用メモリ | 117,588 KB |
実行使用メモリ | 53,208 KB |
最終ジャッジ日時 | 2024-12-14 01:28:25 |
合計ジャッジ時間 | 4,173 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 11 WA * 2 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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]);}}