結果

問題 No.1231 Make a Multiple of Ten
ユーザー WSKRWSKR
提出日時 2020-09-21 22:54:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 245 ms / 2,000 ms
コード長 581 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 87,104 KB
実行使用メモリ 119,512 KB
最終ジャッジ日時 2023-09-07 03:03:52
合計ジャッジ時間 3,939 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,076 KB
testcase_01 AC 69 ms
71,412 KB
testcase_02 AC 71 ms
71,388 KB
testcase_03 AC 71 ms
71,600 KB
testcase_04 AC 158 ms
92,400 KB
testcase_05 AC 143 ms
90,384 KB
testcase_06 AC 108 ms
83,076 KB
testcase_07 AC 159 ms
93,060 KB
testcase_08 AC 123 ms
86,564 KB
testcase_09 AC 94 ms
80,104 KB
testcase_10 AC 149 ms
91,364 KB
testcase_11 AC 164 ms
93,960 KB
testcase_12 AC 237 ms
117,480 KB
testcase_13 AC 241 ms
119,384 KB
testcase_14 AC 71 ms
71,368 KB
testcase_15 AC 245 ms
119,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#make a muptiple of ten

def main():
    N = int(input())
    a = list(map(int, input().split()))
    dp = [[0 for i in range(10)] for j in range(N+1)]
    #dp[X][mod] = index-Xまで見てそれまでの総和がmod である時、これまでで取れる枚数の最大値
    for i in range(10):
        dp[1][i] = -10**18
    dp[1][a[0]%10] = 1        
    for i in range(1,N):
        v = a[i] 
        for j in range(10):
            dp[i+1][j] = max(dp[i][(j-v) % 10]+1, dp[i][j])
    ans = dp[N][0]
    print(max(ans,0))
    return


if __name__ == "__main__":
    main()

0