結果
| 問題 | No.3658 Darumaka Number 2 |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2026-08-31 03:26:42 |
| 言語 | PyPy3 (7.3.23 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 75 ms / 2,000 ms |
| + 885µs | |
| コード長 | 712 bytes |
| 記録 | |
| コンパイル時間 | 235 ms |
| コンパイル使用メモリ | 96,084 KB |
| 実行使用メモリ | 94,000 KB |
| 最終ジャッジ日時 | 2026-08-31 03:26:51 |
| 合計ジャッジ時間 | 5,930 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 45 |
ソースコード
def solve(s: str):
digits = [int(c) for c in s]
lt = False
st = []
for d in digits:
if lt:
st.append(5)
continue
if d > 5:
lt = True
st.append(5)
elif d >= 4:
st.append(d)
else:
n = len(st)
while st and st[-1] == 4:
st.pop()
if len(st) == 0:
st = [5] * (n-1)
lt = True
else:
assert st[-1] == 5
st.pop()
st.append(4)
st.extend([5] * (n - len(st) + 1))
lt = True
return st
N = input()
ans = solve(N)
print(*ans, sep='')
norioc