結果

問題 No.1231 Make a Multiple of Ten
ユーザー ああいいああいい
提出日時 2022-02-23 10:20:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 202 ms / 2,000 ms
コード長 343 bytes
コンパイル時間 398 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 120,216 KB
最終ジャッジ日時 2023-09-14 02:36:51
合計ジャッジ時間 4,516 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
71,608 KB
testcase_01 AC 66 ms
71,224 KB
testcase_02 AC 65 ms
71,440 KB
testcase_03 AC 69 ms
71,388 KB
testcase_04 AC 136 ms
94,368 KB
testcase_05 AC 122 ms
93,064 KB
testcase_06 AC 92 ms
84,976 KB
testcase_07 AC 130 ms
95,520 KB
testcase_08 AC 105 ms
90,884 KB
testcase_09 AC 81 ms
77,988 KB
testcase_10 AC 120 ms
94,144 KB
testcase_11 AC 144 ms
95,584 KB
testcase_12 AC 202 ms
118,528 KB
testcase_13 AC 195 ms
120,216 KB
testcase_14 AC 62 ms
71,348 KB
testcase_15 AC 194 ms
120,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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