結果

問題 No.1231 Make a Multiple of Ten
ユーザー DrDrpilotDrDrpilot
提出日時 2022-03-10 17:17:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 362 bytes
コンパイル時間 355 ms
コンパイル使用メモリ 10,860 KB
実行使用メモリ 111,704 KB
最終ジャッジ日時 2023-10-12 19:40:40
合計ジャッジ時間 15,619 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
12,284 KB
testcase_01 AC 16 ms
7,812 KB
testcase_02 AC 16 ms
7,788 KB
testcase_03 AC 16 ms
7,724 KB
testcase_04 AC 1,428 ms
53,132 KB
testcase_05 AC 1,167 ms
47,704 KB
testcase_06 AC 473 ms
23,532 KB
testcase_07 AC 1,406 ms
55,156 KB
testcase_08 AC 810 ms
34,872 KB
testcase_09 AC 288 ms
17,060 KB
testcase_10 AC 1,254 ms
49,748 KB
testcase_11 AC 1,517 ms
58,572 KB
testcase_12 TLE -
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
a=list(map(int,input().split()))
b=[]
for i in a:
    b.append(i%10)
dp=[[-1]*10 for _ in range(n+1)]
dp[0][0]=0
for i in range(1,n+1):
    num=b[i-1]
    for j in range(10):
        if dp[i-1][j]==-1:
            continue
        dp[i][j]=max(dp[i][j],dp[i-1][j])
        k=(j+num)%10
        dp[i][k]=max(dp[i][k],dp[i-1][j]+1)
print(dp[-1][0])
0