結果

問題 No.1231 Make a Multiple of Ten
ユーザー WSKRWSKR
提出日時 2020-09-21 22:54:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,033 ms / 2,000 ms
コード長 581 bytes
コンパイル時間 1,070 ms
コンパイル使用メモリ 10,764 KB
実行使用メモリ 118,116 KB
最終ジャッジ日時 2023-09-07 03:03:23
合計ジャッジ時間 8,644 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,784 KB
testcase_01 AC 16 ms
7,776 KB
testcase_02 AC 15 ms
7,780 KB
testcase_03 AC 15 ms
7,808 KB
testcase_04 AC 470 ms
58,276 KB
testcase_05 AC 405 ms
51,944 KB
testcase_06 AC 166 ms
25,260 KB
testcase_07 AC 493 ms
60,508 KB
testcase_08 AC 281 ms
38,036 KB
testcase_09 AC 105 ms
18,116 KB
testcase_10 AC 430 ms
54,452 KB
testcase_11 AC 522 ms
64,228 KB
testcase_12 AC 971 ms
112,380 KB
testcase_13 AC 1,022 ms
118,116 KB
testcase_14 AC 16 ms
7,732 KB
testcase_15 AC 1,033 ms
117,796 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