結果

問題 No.1231 Make a Multiple of Ten
ユーザー ygd.ygd.
提出日時 2020-09-18 21:54:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 191 ms / 2,000 ms
コード長 391 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 86,976 KB
実行使用メモリ 114,548 KB
最終ジャッジ日時 2023-09-05 18:18:38
合計ジャッジ時間 3,387 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
71,444 KB
testcase_01 AC 89 ms
71,456 KB
testcase_02 AC 91 ms
71,456 KB
testcase_03 AC 88 ms
71,432 KB
testcase_04 AC 144 ms
89,772 KB
testcase_05 AC 131 ms
86,716 KB
testcase_06 AC 111 ms
80,280 KB
testcase_07 AC 142 ms
91,592 KB
testcase_08 AC 122 ms
85,492 KB
testcase_09 AC 105 ms
78,596 KB
testcase_10 AC 136 ms
88,848 KB
testcase_11 AC 146 ms
92,388 KB
testcase_12 AC 187 ms
113,864 KB
testcase_13 AC 191 ms
114,436 KB
testcase_14 AC 86 ms
71,632 KB
testcase_15 AC 189 ms
114,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import copy
N = int(input()); INF = float("inf")
A = list(map(int,input().split()))

dp = [-INF for _ in range(10)] #dp[i+1][j] i番目まで見て和の1の位がjとなる最大選択可能個数
dp[0] = 0
for i in range(N):
  p = copy.copy(dp)
  p,dp = dp,p
  now = A[i]
  for j in range(10):
    dp[(j+now)%10] = max(dp[(j+now)%10], p[j]+1)
  #print(dp)
#print(dp)
ans = dp[0]
print(ans)
0