結果

問題 No.1231 Make a Multiple of Ten
ユーザー ronpooronpoo
提出日時 2023-10-31 10:07:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 205 ms / 2,000 ms
コード長 352 bytes
コンパイル時間 214 ms
コンパイル使用メモリ 81,848 KB
実行使用メモリ 118,488 KB
最終ジャッジ日時 2023-10-31 10:07:05
合計ジャッジ時間 4,077 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,584 KB
testcase_01 AC 34 ms
53,584 KB
testcase_02 AC 35 ms
53,584 KB
testcase_03 AC 35 ms
53,584 KB
testcase_04 AC 113 ms
94,084 KB
testcase_05 AC 105 ms
92,764 KB
testcase_06 AC 77 ms
83,624 KB
testcase_07 AC 114 ms
95,540 KB
testcase_08 AC 91 ms
90,164 KB
testcase_09 AC 61 ms
73,856 KB
testcase_10 AC 110 ms
94,152 KB
testcase_11 AC 116 ms
95,468 KB
testcase_12 AC 196 ms
108,472 KB
testcase_13 AC 205 ms
118,384 KB
testcase_14 AC 34 ms
53,584 KB
testcase_15 AC 205 ms
118,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))

dp = [[-1]*10 for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
    m = A[i] % 10       
    for j in range(10):
        if dp[i][j] == -1:
            continue
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])
        x = (m+j)%10
        dp[i+1][x] = max(dp[i+1][x], dp[i][j] + 1)
print(dp[N][0])
0