結果

問題 No.1231 Make a Multiple of Ten
ユーザー rlangevinrlangevin
提出日時 2023-01-01 19:38:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 294 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 82,400 KB
実行使用メモリ 107,392 KB
最終ジャッジ日時 2024-05-05 05:57:03
合計ジャッジ時間 3,738 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,516 KB
testcase_01 AC 35 ms
52,096 KB
testcase_02 AC 38 ms
51,840 KB
testcase_03 AC 38 ms
51,712 KB
testcase_04 AC 95 ms
88,784 KB
testcase_05 AC 99 ms
87,168 KB
testcase_06 AC 62 ms
77,184 KB
testcase_07 AC 96 ms
90,712 KB
testcase_08 AC 75 ms
82,048 KB
testcase_09 AC 54 ms
71,296 KB
testcase_10 AC 90 ms
88,832 KB
testcase_11 AC 96 ms
90,752 KB
testcase_12 AC 144 ms
107,392 KB
testcase_13 AC 153 ms
101,672 KB
testcase_14 AC 36 ms
51,840 KB
testcase_15 AC 151 ms
101,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
inf = 10 ** 18
pre = [-inf] * 10
pre[0] = 0
for i in range(N):
    dp = [-inf] * 10
    for j in range(10):
        dp[j] = max(dp[j], pre[j])
        dp[(j + A[i])%10] = max(dp[(j + A[i])%10], pre[j] + 1)
    dp, pre = pre, dp
print(pre[0])
0