結果
| 問題 | No.1231 Make a Multiple of Ten |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2026-06-15 04:40:23 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 308 ms / 2,000 ms |
| コード長 | 599 bytes |
| 記録 | |
| コンパイル時間 | 177 ms |
| コンパイル使用メモリ | 85,248 KB |
| 実行使用メモリ | 113,536 KB |
| 最終ジャッジ日時 | 2026-06-15 04:40:27 |
| 合計ジャッジ時間 | 3,284 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
ソースコード
import operator
def accum_dp(xs: list, f, op, e, init: dict, *, is_reset=True):
dp = init.copy()
for x in xs:
pp = {} if is_reset else dp.copy()
dp, pp = pp, dp
for fm_key, fm_val in pp.items():
for to_key, to_val in f(fm_key, fm_val, x):
dp[to_key] = op(dp.get(to_key, e), to_val)
return dp
def f(k, v, x):
# 取る
nk = (k + x) % 10
yield nk, v+1
# 取らない
yield k, v
N = int(input())
A = list(map(int, input().split()))
init = {0: 0}
dp = accum_dp(A, f, max, 0, init)
ans = dp.get(0, 0)
print(ans)
norioc