結果

問題 No.1231 Make a Multiple of Ten
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2020-09-18 21:32:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 308 bytes
コンパイル時間 1,116 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 107,136 KB
最終ジャッジ日時 2024-06-23 13:38:58
合計ジャッジ時間 2,696 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,096 KB
testcase_01 AC 38 ms
51,584 KB
testcase_02 AC 37 ms
52,096 KB
testcase_03 AC 38 ms
51,584 KB
testcase_04 AC 118 ms
89,216 KB
testcase_05 AC 106 ms
87,296 KB
testcase_06 AC 78 ms
78,848 KB
testcase_07 AC 120 ms
90,752 KB
testcase_08 AC 89 ms
82,176 KB
testcase_09 AC 69 ms
76,928 KB
testcase_10 AC 110 ms
88,832 KB
testcase_11 AC 121 ms
90,880 KB
testcase_12 AC 174 ms
107,136 KB
testcase_13 AC 187 ms
101,632 KB
testcase_14 AC 39 ms
52,096 KB
testcase_15 AC 186 ms
101,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

dp = [float("-inf")] * 10
dp[0] = 0

for i in range(N):

    ndp = [float("-inf")] * 10

    for j in range(10):

        ndp[j] = max(ndp[j] , dp[j])
        ndp[(A[i] + j) % 10] = max( ndp[(A[i] + j) % 10] , dp[j] + 1)

    dp = ndp
    
print (dp[0])
0