結果
問題 | No.3015 右に寄せろ! |
ユーザー |
|
提出日時 | 2025-01-25 13:35:05 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 238 ms / 2,000 ms |
コード長 | 652 bytes |
コンパイル時間 | 290 ms |
コンパイル使用メモリ | 82,232 KB |
実行使用メモリ | 146,140 KB |
最終ジャッジ日時 | 2025-01-25 22:51:21 |
合計ジャッジ時間 | 4,204 ms |
ジャッジサーバーID (参考情報) |
judge8 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 36 |
ソースコード
import sys input = lambda: sys.stdin.readline().rstrip() def main(): # 入力 S = input() # 計算・出力 RLE = [['0', 0]] def RLEappend(s, n): if n <= 0: return if RLE[-1][0] == s: RLE[-1][1] += n else: RLE.append([s, n]) ans = 0 for s in S: if s == '0' and RLE[-1][0] == '1': _, one = RLE.pop() d, r = divmod(one, 2) ans += d RLEappend('1', r) RLEappend('0', 1) RLEappend('1', 2*d) else: RLEappend(s, 1) print(ans) if __name__ == "__main__": main()