← Back to List

26026번: Coffee Cup Combo ↗

Solutions

Python 3
156 B | 156 chars
input()
s = input()

ans = 0
crt = 0

for i in s:
  if i == '1':
    crt = 2
    ans += 1
  else:
    if crt > 0:
      ans += 1
      crt -= 1

print(ans)