CSES - HIIT Open 2018 - Results
Submission details
Task:Inversions
Sender:TreamDeam
Submission time:2018-05-26 11:19:46 +0300
Language:Python3
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.37 sdetails
#2ACCEPTED0.34 sdetails
#3ACCEPTED0.36 sdetails
#4ACCEPTED0.32 sdetails
#5ACCEPTED0.33 sdetails

Code

n = input().rstrip()
a, b = 0, 0
for i, el in enumerate(n):
 if i % 2 == 0:
  if el == '0':
   b += 1
  else:
   a += 1
 else:
  if el == '0':
   a += 1
  else:
   b += 1

print(min(a,b))

Test details

Test 1

Verdict: ACCEPTED

input
000000000000000000000000000000...

correct output
500000

user output
500000

Test 2

Verdict: ACCEPTED

input
111111111111111111111111111111...

correct output
500000

user output
500000

Test 3

Verdict: ACCEPTED

input
010101010101010101010101010101...

correct output
0

user output
0

Test 4

Verdict: ACCEPTED

input
101010101010101010101010101010...

correct output
0

user output
0

Test 5

Verdict: ACCEPTED

input
110101011010110100100111110110...

correct output
499476

user output
499476