結果

問題 No.3015 右に寄せろ!
ユーザー urunea
提出日時 2025-03-22 00:10:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 325 ms / 2,000 ms
コード長 461 bytes
コンパイル時間 447 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 252,276 KB
最終ジャッジ日時 2025-03-22 00:10:32
合計ジャッジ時間 6,489 ms
ジャッジサーバーID
(参考情報)
judge3 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

S=list(map(int, input()))
res=[]
row=[]
row.append(S[0])
for i in range(1, len(S)):
    if S[i] == S[i-1]:
        row.append(S[i])
    else:
        res.append(row)
        row=[S[i]]
res.append(row)

count=0
ans=0
p=0
for num,i in enumerate(res):
  if i[0] == 1:
    count += len(i)
  else:
    if count == 1:
      count=0
      continue
    if count%2 == 0:
      ans += (count//2)*len(i)
    else:
      ans += (count//2)*len(i)
      count -= 1
print(ans)
0