結果
| 問題 | No.3658 Darumaka Number 2 |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2026-08-30 16:09:20 |
| 言語 | PyPy3 (7.3.23) |
| 結果 |
AC
|
| 実行時間 | 82 ms / 2,000 ms |
| + 210µs | |
| コード長 | 794 bytes |
| 記録 | |
| コンパイル時間 | 241 ms |
| コンパイル使用メモリ | 96,356 KB |
| 実行使用メモリ | 93,952 KB |
| 最終ジャッジ日時 | 2026-08-30 16:09:26 |
| 合計ジャッジ時間 | 6,132 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 45 |
ソースコード
N = input()
def solve():
digits = [int(c) for c in N]
if digits[0] < 4:
return [5] * (len(digits) - 1)
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)))
st.append(5)
lt = True
return st
ans = solve()
print(*ans, sep='')
norioc