結果

問題 No.1231 Make a Multiple of Ten
ユーザー 👑 horiesinitihoriesiniti
提出日時 2023-02-15 03:06:31
言語 Ruby
(3.3.0)
結果
AC  
実行時間 900 ms / 2,000 ms
コード長 311 bytes
コンパイル時間 458 ms
コンパイル使用メモリ 11,276 KB
実行使用メモリ 62,856 KB
最終ジャッジ日時 2023-09-24 13:22:05
合計ジャッジ時間 9,345 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,316 KB
testcase_01 AC 79 ms
15,124 KB
testcase_02 AC 78 ms
15,212 KB
testcase_03 AC 76 ms
15,280 KB
testcase_04 AC 451 ms
36,884 KB
testcase_05 AC 408 ms
33,972 KB
testcase_06 AC 205 ms
22,272 KB
testcase_07 AC 485 ms
37,764 KB
testcase_08 AC 302 ms
27,516 KB
testcase_09 AC 152 ms
19,100 KB
testcase_10 AC 424 ms
35,212 KB
testcase_11 AC 508 ms
39,304 KB
testcase_12 AC 858 ms
59,932 KB
testcase_13 AC 894 ms
62,328 KB
testcase_14 AC 76 ms
15,048 KB
testcase_15 AC 900 ms
62,856 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

dp=[]
n=gets.to_i
(n+1).times{
	dp<<Array.new(10,-1)
}
dp[0][0]=0
ans=0
xs=gets.split(" ").map{|e| e.to_i}
n.times{|i|
	x=xs[i]
	0.upto(9){|j|
		next if dp[i][j]==-1
		p1=(j+x)%10
		dp[i+1][p1]=[dp[i+1][p1],dp[i][j]+1].max
		dp[i+1][j]=[dp[i+1][j],dp[i][j]].max
		ans=[ans,dp[i+1][0]].max if p1==0
	}
}
puts ans
0