結果

問題 No.1231 Make a Multiple of Ten
ユーザー DrDrpilotDrDrpilot
提出日時 2022-03-10 17:16:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 259 ms / 2,000 ms
コード長 362 bytes
コンパイル時間 1,520 ms
コンパイル使用メモリ 86,676 KB
実行使用メモリ 131,164 KB
最終ジャッジ日時 2023-10-12 19:38:28
合計ジャッジ時間 3,823 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,400 KB
testcase_01 AC 71 ms
71,292 KB
testcase_02 AC 72 ms
71,480 KB
testcase_03 AC 73 ms
71,096 KB
testcase_04 AC 154 ms
98,516 KB
testcase_05 AC 145 ms
96,652 KB
testcase_06 AC 115 ms
86,544 KB
testcase_07 AC 168 ms
100,728 KB
testcase_08 AC 129 ms
92,336 KB
testcase_09 AC 104 ms
81,384 KB
testcase_10 AC 149 ms
98,696 KB
testcase_11 AC 172 ms
100,752 KB
testcase_12 AC 252 ms
130,732 KB
testcase_13 AC 259 ms
131,164 KB
testcase_14 AC 73 ms
71,400 KB
testcase_15 AC 256 ms
131,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
a=list(map(int,input().split()))
b=[]
for i in a:
    b.append(i%10)
dp=[[-1]*10 for _ in range(n+1)]
dp[0][0]=0
for i in range(1,n+1):
    num=b[i-1]
    for j in range(10):
        if dp[i-1][j]==-1:
            continue
        dp[i][j]=max(dp[i][j],dp[i-1][j])
        k=(j+num)%10
        dp[i][k]=max(dp[i][k],dp[i-1][j]+1)
print(dp[-1][0])
0