Problem:


Score : 300 points

Problem Statement

There are N stones arranged in a row. Every stone is painted white or black.
A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is ., and the stone is black if the character is #.

Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone.
Find the minimum number of stones that needs to be recolored.

Constraints

1 \leq N \leq 2\times 10^5

S is a string of length N consisting of . and #.

Input

Input is given from Standard Input in the following format:

N
S

Output

Print the minimum number of stones that needs to be recolored.

Sample Input 1

3
#.#

Sample Output 1

1

It is enough to change the color of the first stone to white.

Sample Input 2

5
#.##.

Sample Output 2

2

Sample Input 3

9
.........

Sample Output 3

0



Sample input:
3
#.#


Sample output:
1

Submission status: Wrong Answer

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

# 四方向
dy = [0, 0, 1, -1]
dx = [1, -1, 0, 0]
INF = float("inf")

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))

N = int(input())
S = input()

l = [0] * (N+1)

for i, si in enumerate(S):
    if si == "#":
        l[i+1] = l[i] + 1
    else:
        l[i+1] = l[i]

ans = INF
for i in range(1, N+1):
    l_black = l[i]
    r_white = (N - i) - (l[-1] - l[i])
    ans = min(ans, (l_black + r_white))

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
S2 = S.copy()

res = 0
res2 = 0
for i in range(1,N):
    if S[i]=='.' and S[i-1]=='#':
        S[i]='#'
        res+=1

    if S2[i]=='#' and S2[i-1]=='.':
        S2[i]='.'
        res2+=1

if res>res2:
    print(res2)
else:
    print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

dot = S.count(".")
sha = 0
res = 10**9
for i in range(0,N):
    if S[i] == "#":
        sha += 1
    else:
        dot -= 1
    tmp = sha + dot
    res = min(res, tmp)

print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
S2 = S.copy()

res = 0
res2 = 0
for i in range(N):
    if S[i]=='.' and S[i-1]=='#':
        S[i]='#'
        res+=1

    if S2[i]=='#' and S2[i-1]=='.':
        S2[i]='.'
        res2+=1

if res>res2:
    print(res2)
else:
    print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
S2 = S.copy()

res = 0
res2 = 0
for i in range(N):
    if S[i]=='.' and S[i-1]=='#':
        S[i]='#'
        res+=1

    if S2[i]=='.' and S2[i-1]=='#':
        S2[i]='#'
        res2+=1

if res>res2:
    print(res2)
else:
    print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

dot = S.count(".")
sha = 0
res = 10**9
for i in range(1,N):
    if i == "#":
        sha += 1
    else:
        dot -= 1
    tmp = sha + dot
    res = min(res, tmp)

print(res)

Submission status: Wrong Answer

Solution code:
import re
n = int(input())
s = '.'+input()
ans = []

def div(i, s):
  l = s[:i.start()+1]
  r = s[i.end()-1:]
  lb = l.count('#')
  rw = r.count('.')
  return l, lb, r, rw
  
for i in re.finditer(r'#\.', s):
  l, lb, r, rw = div(i, s)
  #print(l, lb, r, rw)
  ans.append(lb+rw)
#print()
for i in re.finditer(r'\.#', s):
  l, lb, r, rw = div(i, s)
  #print(l, lb, r, rw)
  ans.append(lb+rw)
#print('\n',ans)
if len(ans) > 0:
  print(min(ans))
else:
  print(0)

Submission status: Wrong Answer

Solution code:
a = int(input())
ar = list(input())
go = "OFF"
count = 0
for i in range(a):
    if go == "ON":
        if ar[i] == "." and ar[i-1] == "#":
            count += 1
    else:
        if ar[i] == "#":
            go = "ON"
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
ans = N
pos = 0
# S = [S[n] == '#' for n in range(N)]
sumB = [0] * N
tmp = 0
for i in range(N):
    if S[i] == '#':
        tmp += 1
    sumB[i] = tmp
cntB = 0
for i in range(N):
    ans = min(sumB[i] + (N - i - 1) - (sumB[N-1] - sumB[i]), ans)

    # print(sumB[i] , (N - i - 1) - (sumB[N-1] - sumB[i]), ans)
print(ans)

Submission status: Wrong Answer

Solution code:
a = int(input())
ar = list(input())
wh = 0
bl = 0
go = "OFF"
for r in ar:
    if go == "ON":
        if r == "#":
            bl += 1
        else:
            wh += 1
    else:
        if r == "#":
            go = "ON"
            bl += 1
print(min(wh,bl))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
import re
b, w = 0, 0
for sub in re.finditer(r'#+\.+', s):
  b += sub.group().count('#')
  w += sub.group().count('.')
print(min(b,w))

Submission status: Wrong Answer

Solution code:
import re
s = '........#####...###.'
b, w = 0, 0
for sub in re.finditer(r'#+\.+', s):
  b += sub.group().count('#')
  w += sub.group().count('.')
print(min(b,w))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
bcnt = [0]*n
wcnt = [0]*n
result = 2 * 10 ** 5

# 累積和
if s[0] == "#":
    bcnt[0] = 1
if s[n-1] == ".":
    wcnt[n-1] = 1

for i in range(1,n):
    bcnt[i] = bcnt[i-1]
    if s[i] == "#":
        bcnt[i] += 1
for i in range(n-2,-1,-1):
    wcnt[i] = wcnt[i+1]
    if s[i] == ".":
        wcnt[i] += 1

# 最小コストを求める
for i in range(0,n-1):
    result = min(bcnt[i] + wcnt[n-2-i],result)

result = min(result,bcnt[n-1])
result = min(result,wcnt[0])

print(result)

Submission status: Wrong Answer

Solution code:
SIRO = '.'
KURO = '#'
N = int(input())
S = input()
sCnt = S.count(SIRO)
kCnt = 0
ans = 100001
for i in S:
    if i == KURO:
        kCnt += 1
    else:
        sCnt -= 1
    ans = min(ans, kCnt + sCnt)
print(ans)

Submission status: Wrong Answer

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N=_I()
S=input()
#print(S)

black=0
white=S.count(".")
ans=inf
for idx in range(len(S)):
	if S[idx] == "#":
		black+=1
	else:
		white-=1
	ans=min(ans,black+white)


	
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())

list_b = []
cnt_b = 0
list_w = []
cnt_w = 0
for i in range(n):
    if s[i] == "#":
        cnt_b += 1
    else:
        cnt_w += 1
    list_b.append(cnt_b)
    list_w.append(cnt_w)
print(list_b)
print(list_w)
ans = 2*10**5
for i in range(n):
    if ans > list_b[i] + list_w[n-1] - list_w[i]:
        ans = list_b[i] + list_w[n-1] - list_w[i]
print(min(ans,list_b[n-1],list_w[n-1]))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
ans = N
pos = 0
S = [S[n] == '#' for n in range(N)]
cntB = 0
for index in range(N):
    if S[index]:
        cntB += 1
    ans = min(cntB + (N -(index+1) -sum(S[index+1:N])), ans)

    # print(cntB,(N -(index+1) -sum(S[index+1:N])))
print(ans)

Submission status: Wrong Answer

Solution code:
SIRO = '.'
KURO = '#'
N = int(input())
S = input()
sLst = [0] * N
kLst = [0] * N
sCnt = 0
kCnt = 0
for i in range(N):
    if S[i] == KURO:
        kCnt += 1
    kLst[i] = kCnt
for i in range(N - 1, 0, -1):
    if S[i] == SIRO:
        sCnt += 1
    sLst[-i - 1] = sCnt

ans = kLst[0] + sLst[0]
for i in range(1, N):
    ans = min(ans, kLst[i] + sLst[i])

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())

list_b = []
cnt_b = 0
list_w = []
cnt_w = 0
for i in range(n):
    if s[i] == "#":
        cnt_b += 1
    else:
        cnt_w += 1
    list_b.append(cnt_b)
    list_w.append(cnt_w)

ans = 2*10**5
for i in range(n):
    if ans > list_b[i] + list_w[n-1] - list_w[i]:
        ans = list_b[i] + list_w[n-1] - list_w[i]
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()

a = s.count('.')
b = 0

ans = a
print(ans)

for i in range(n):
    if s[i] == '#':
        b += 1
    else:
        a -= 1
    print(a+b)
    ans = min(ans,a+b)

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

base = min(S.count('#'), S.count('.'))
ans = base
for i in range(N + 1):
    left_num = S[:i].count('#')
    right_num = S[i:].count('.')

    if right_num == N - i:
        right_num = 0
    ans = min(ans, (left_num + right_num))
    if right_num in [0, N - i] or ans >= base:
        break
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

n = int(input())
s = list(input())
res = 10**9



ctw = 0
ctb = 0
w = [0]*n
b = [0]*n
for i in range(n):
     if s[i] == ".":
          ctw += 1
     else:
          ctb += 1
     w[i]= ctw
     b[i]= ctb
res = min(res,b[-1]+w[-1]-w[-1])
res = min(res,w[-1],b[-1])
print(res)

Submission status: Wrong Answer

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N=_I()
S=input()
#print(S)
for sidx in range(N):
	#print("a",sidx)

	if S[sidx]=="#":
		S=S[sidx:]
		break
if len(S)==0:
	print(0)
	exit()

#print(S)
S=S[::-1]
for sidx in range(len(S)):
	if S[sidx]==".":
		S=S[sidx:]
		break
if len(S)==0:
	print(0)
	exit()

#print(S)
S=S[::-1]

black=0
white=S.count(".")
ans=inf
for idx in range(len(S)):
	if S[idx] == "#":
		black+=1
	else:
		white-=1
	ans=min(ans,black+white)
	
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
white=s.count('.')
black=s.count('#')
print(min(white,black))

Submission status: Wrong Answer

Solution code:
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0]*n

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                w = cmt + ': ' + str(x)
            else:
                w = str(x)
            print(w)
        return x

def prob():
    d = Debug()
    d.off()
    N = getInt()
    S = input()
    d.dmp((N, S),'N, S')
    i = 0
    while i < N and S[i] == '.':
        i += 1
    j = N-1
    while i <= j and S[j] == '#':
        j -= 1
    d.dmp((i,j),'i,j')
    blackCount, whiteCount = 0, 0
    k = i
    for k in range(i, j+1):
        if S[k] == '.':
            whiteCount += 1
        else:
            blackCount += 1
    d.dmp((blackCount, whiteCount),'blackCount, whiteCount')
    return min(blackCount, whiteCount)

ans = prob()
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
white = [ 0 for i in range(n+1) ]
black = [ 0 for i in range(n+1) ]
for i in range(1,n+1):
    white[i] = white[i-1]
    black[i] = black[i-1]
    if s[i-1] == '.':
        white[i]+=1
    else:
        black[i]+=1
ans = min(white[n] , black[n] )
for i in range(1,n+1):
    a = black[i]
    b = white[n] - white[i-1]
    ans = min( ans, a+b)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
white = [ 0 for i in range(n+1) ]
black = [ 0 for i in range(n+1) ]
for i in range(1,n+1):
    white[i] = white[i-1]
    black[i] = black[i-1]
    if s[i-1] == '.':
        white[i]+=1
    else:
        black[i]+=1
ans = min( n - white[n] , n - black[n] )
for i in range(1,n):
    a = black[i]
    b = white[n] - white[i-1]
    ans = min( ans, a+b)
print(ans)

Submission status: Wrong Answer

Solution code:

import sys
input = sys.stdin.readline

n = int(input())
s = list(input())
res = 10**9



ctw = 0
ctb = 0
w = [0]*n
b = [0]*n
print(w)
for i in range(n):
     if s[i] == ".":
          ctw += 1
     else:
          ctb += 1
     w[i]= ctw
     b[i]= ctb
for i in range(n):
     res = min(res,b[i]+w[-1]-w[i])
res = min(res,w[-1],b[-1])
print(res)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

n = int(input())
s = list(input())
res = 10**9



ctw = 0
ctb = 0
w = [0]*n
b = [0]*n

for i in range(n):
     if s[i] == ".":
          ctw += 1
     else:
          ctb += 1
     w[i]= ctw
     b[i]= ctb
for i in range(n):
     res = b[i]+w[-1]-w[i]
res = min(res,w[-1],b[-1])
print(res)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=str(input())
m=1000
for  i in range(N):
  a=S[:i].count("#")
  b=S[i:].count(".")
  c=a+b
  if m>=c:
    m=c
print(m)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

n = int(input())
s = list(input())
res = 10**9



ctw = 0
ctb = 0
w = [0]*n
b = [0]*n

for i in range(n):
     if s[i] == ".":
          ctw += 1
     else:
          ctb += 1
     w[i]= ctw
     b[i]= ctb
"""for i in range(n):
     res = min(res,b[i]+w[-1]-w[i])"""
res = min(res,w[-1],b[-1])
print(res)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=str(input())
m=100000000000
for  i in range(N):
  a=S[:i].count("#")
  b=S[i:].count(".")
  c=a+b
  if m>=c:
    m=c
print(m)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
a = list(S)
b = N
for i in range(1, N):
    c = S[0: i].count("#")
    d = S[i+1: N].count(".")
    if c + d < b:
        b = c + d
print(b)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

tmp = True
l = 0

ct = S.count('.')
for i in range(N):
    if S[i] == '.' and tmp:
        l += 1
    if S[i] == '#' and tmp:
        tmp = False
print(min(ct - l, N - ct))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

ans = N
for i in range(N + 1):
    print(i)
    left_num = S[:i].count('#')
    right_num = S[i:].count('.')
    ans = min(ans, (left_num + right_num))
    if right_num in [0, N - i]:
        break
print(ans)

Submission status: Wrong Answer

Solution code:
stone=input()
color=input()
a=int(stone)
result=100000
counter=0
left=''
right=''
black = 0
white = 0
xxx=[]
yyy=[]
list=[]
list2=[]
for i in range(a):
	left=color[:i]
	right=color[i:]
	w=left.count('#')
	b=right.count('.')
	if result > w+b:
		result=w+b
print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
 
arr = [0] if S[0] == "." else []
b, w = 0, 0
for i in range(len(S)):
  if S[i] == ".":
    w += 1
  else:
    b += 1
  if S[i:i+2] == "#.":
    arr.append(b)
  if S[i:i+2] == ".#":
    arr.append(w)
if S[-1] == ".":
  arr.append(w)
print(arr)

result = w
for i in range(0, len(arr), 2):
  result = min([arr[i]+w-arr[i+1], result])

print(result)

Submission status: Wrong Answer

Solution code:
stone=input()
color=input()
a=int(stone)
result=100000
counter=0
left=[]
right=[]
black = 0
white = 0
xxx=[]
yyy=[]
list=[]
list2=[]
for i in range(a):
	left=color[:i]
	right=color[i:]
	w=left.count('#')
	b=right.count('.')
	if result > w+b:
		result=w+b
print(result)

Submission status: Wrong Answer

Solution code:
stone=input()
color=input()
a=int(stone)
result=100000
counter=0
left=[]
right=[]
black = 0
white = 0
xxx=[]
yyy=[]
list=[]
list2=[]
for i in range(a):
    list.append(color[i])
for i in range(a):
	left=color[:i]
	right=color[i:]
	w=left.count('#')
	b=right.count('.')
	if result > w+b:
		result=w+b
print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
 
arr = [0] if S[0] == "." else []
b, w = 0, 0
for i in range(len(S)):
  if S[i] == ".":
    w += 1
  else:
    b += 1
  if S[i:i+2] == "#.":
    arr.append(b)
  if S[i:i+2] == ".#":
    arr.append(w)
if S[-1] == ".":
	arr.append(w)
#print(arr)

result = 10 ** 10
for i in range(0, len(arr), 2):
  result = min([arr[i]+arr[-1]-arr[i+1], result])

print(result)

Submission status: Wrong Answer

Solution code:
stone=input()
color=input()
a=int(stone)
result=100000
counter=0
counter2=0
black = 0
white = 0
xxx=[]
yyy=[]
list=[]
list2=[]
for i in range(a):
    list.append(color[i])
for i in range(a):
    for j in range(0,i):
        if list[j]=='#':
            counter = counter+1
    for k in range(i,a):
        if list[k]=='.':
            counter = counter+1
    if result > counter:
      result=counter
print(result)

Submission status: Wrong Answer

Solution code:
def C(N, S):
    min_n_diff_chars = 2 * 10 ** 5
    for i in range(N):
        cand = "." * i + "#" * (N-i)
        n_diff_chars = sum(a!=b for a, b in zip(cand, S))
#       print(cand, n_diff_chars)
        min_n_diff_chars = min(min_n_diff_chars, n_diff_chars)
    print(min_n_diff_chars)

if __name__ == "__main__":
    N = int(input())
    S = input()
    C(N, S)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
 
arr = [0] if S[0] == "." else []
count = 0
for i in range(len(S)):
  count += 1
  if S[i:i+2] == "#.":
    arr.append(count)
    count = 0  
  if S[i:i+2] == ".#":
    arr.append(count)
    count = 0
arr.append(count)
#print(arr)

result = 10 ** 10
for i in range(0, len(arr), 2):
  result = min([sum(arr[:i][::2])+sum(arr[i:][1::2]), result])

print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
ans = N
pos = 0
S = [S[n] == '#' for n in range(N)]
for index in range(N):
    ans = min(sum(S[0:index])+(N -index -sum(S[index:N])), ans)

    # print(index, sum(S[0:index]),(N -index -sum(S[index:N])))
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
S = input()

ans = [np.zeros(N), np.zeros(N)]

for i in range(N):
    if S[i] == "#":
        ans[0][i:] += 1
    else:
        ans[1][:i+1] += 1

a = [ans[1][0]]
for i in range(N-1):
    a.append(ans[0][i]+ans[1][i+1])
a.append(ans[0][N-1])

print(min(a))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

CW = 0

for s in S:
    if s == '.' : CW += 1
    
CB = 0
ans = 2**30
for s in S:
    if s == '.' : CW -= 1
    if s == '#' : CB += 1
    ans = min(ans,CB+CW)
    
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s = input()
n=len(s)
x = 0
for i in range(n):
    if s[i] == "." and s[i - 1] == "#":
        y1=0
        for j in reversed(range(i)):
            if s[j] == "#":
                y1 += 1
            else:
                break
        y2=0
        for k in range(i, n):
            if s[k] == ".":
                y2 += 1
            else:
                break

        x += min(y1, y2)
print(str(x))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()

b = [0]  # 黒の累積和
w = [0]  # 白の累積和

count_b = 0
count_w = 0
for i in range(n):
    if s[i] == "#":
        # 黒なら
        count_b += 1
    else:
        # 白なら
        count_w += 1
    b.append(count_b)
    w.append(count_w)

ans = n
for i in range(n+1):
    ans = min(ans, b[i]+w[n-1]-w[i])
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
sr = s[::-1]

ans = s.count(".")
for i in range(n):
    if s[i] == ".":
        num = ans - 1
    else:
        num = ans + 1
    ans = min(num, ans)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
black = 0
white = s.count('.')
min = n

if white == 0:
    print(0)
    exit()

for i in range(n):
    if s[i] == "#":
        black += 1
    else:
        white -= 1

    if black+white < min:
        min = black+white
print(min)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
n=len(s)
x = 0
for i in range(n):
    #if s[i] == "#" and s[i + 1] == ".":
        y1=0
        for j in reversed(range(i)):
            if s[j] == "#":
                y1 += 1
            else:
                break
        y2=0
        for k in range(i, n):
            if s[k] == ".":
                y2 += 1
            else:
                break

        x += min(y1, y2)
print(str(x))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
black = 0
white = 0
min = n

for i in range(n):
    if s[i] == ".":
        white += 1
if white == 0:
    print(0)
    exit()

for i in range(n):
    if s[i] == "#":
        black += 1
    else:
        white -= 1

    if black+white < min:
        min = black+white
print(min)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
sr = s[::-1]

ans = n
num = s.count(".")
for i in range(n):
    if s[i] == ".":
        num -= 1
    else:
        num += 1
    ans = min(num, ans)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
black = 0
white = 0
min = n

for i in range(n):
    if s[i] == ".":
        white += 1
    if white == 0:
        print(0)
        exit()

for i in range(n):
    if s[i] == "#":
        black += 1
    else:
        white -= 1

    if black+white < min:
        min = black+white
print(min)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = str(input())
# '.'の場合は白, '#'の場合は黒

if S[0] == '.':
    count_white = [1]
    count_black = [0]
else:
    count_white = [0]
    count_black = [1]


for i in range(1, N):
    if S[i] == '.':
        # 見ている石が白なら
        count_white.append(count_white[i-1]+1)
        count_black.append(count_black[i-1])
    else:
        # 見ている石が黒なら
        count_white.append(count_white[i-1])
        count_black.append(count_black[i-1]+1)

tmp = 9999999999
for i in range(1, N):
    min_sum = 0
    min_sum += count_black[i-1]
    min_sum += (count_white[N-1] - count_white[i])
    tmp = min(tmp, min_sum)

print(tmp)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
black = 0
white = 0
min = n

for i in range(n):
    if s[i] == ".":
        white += 1
for i in range(n):
    if s[i] == "#":
        black += 1
    else:
        white -= 1

    if black+white < min:
        min = black+white
print(min)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = str(input())
# '.'の場合は白, '#'の場合は黒

if S[0] == '.':
    count_white = [1]
    count_black = [0]
else:
    count_white = [0]
    count_black = [1]


for i in range(1, N):
    if S[i] == '.':
        # 見ている石が白なら
        count_white.append(count_white[i-1]+1)
        count_black.append(count_black[i-1])
    else:
        # 見ている石が黒なら
        count_white.append(count_white[i-1])
        count_black.append(count_black[i-1]+1)

hoge = []
for i in range(N):
    min_sum = 0
    min_sum += count_black[i]
    min_sum += (count_white[N-1] - count_white[i])
    hoge.append(min_sum)

print(min(hoge))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = str(input())
# '.'の場合は白, '#'の場合は黒

if S[0] == '.':
    count_white = [1]
    count_black = [0]
else:
    count_white = [0]
    count_black = [1]


for i in range(1, N):
    if S[i] == '.':
        # 見ている石が白なら
        count_white.append(count_white[i-1]+1)
        count_black.append(count_black[i-1])
    else:
        # 見ている石が黒なら
        count_white.append(count_white[i-1])
        count_black.append(count_black[i-1]+1)

tmp = 0
for i in range(N):
    min_sum = 0
    min_sum += count_black[i]
    min_sum += (count_white[N-1] - count_white[i])
    tmp = min(tmp, min_sum)

print(tmp)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = str(input())
# '.'の場合は白, '#'の場合は黒

if S[0] == '.':
    count_white = [1]
    count_black = [0]
else:
    count_white = [0]
    count_black = [1]


for i in range(1, N):
    if S[i] == '.':
        # 見ている石が白なら
        count_white.append(count_white[i-1]+1)
        count_black.append(count_black[i-1])
    else:
        # 見ている石が黒なら
        count_white.append(count_white[i-1])
        count_black.append(count_black[i-1]+1)

tmp = 0
for i in range(1, N):
    min_sum = 0
    min_sum += count_black[i-1]
    min_sum += (count_white[N-1] - count_white[i])
    tmp = min(tmp, min_sum)

print(tmp)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = str(input())
# '.'の場合は白, '#'の場合は黒

if S[0] == '.':
    count_white = [1]
    count_black = [0]
else:
    count_white = [0]
    count_black = [1]


for i in range(1, N):
    if S[i] == '.':
        # 見ている石が白なら
        count_white.append(count_white[i-1]+1)
        count_black.append(count_black[i-1])
    else:
        # 見ている石が黒なら
        count_white.append(count_white[i-1])
        count_black.append(count_black[i-1]+1)

tmp = 0
for i in range(1, N):
    min_sum = 0
    min_sum += count_black[i-1]
    min_sum += (count_white[N-1] - count_white[i-1])
    tmp = min(tmp, min_sum)

print(tmp)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = str(input())
# '.'の場合は白, '#'の場合は黒

if S[0] == '.':
    count_white = [1]
    count_black = [0]
else:
    count_white = [0]
    count_black = [1]


for i in range(1, N):
    if S[i] == '.':
        # 見ている石が白なら
        count_white.append(count_white[i-1]+1)
        count_black.append(count_black[i-1])
    else:
        # 見ている石が黒なら
        count_white.append(count_white[i-1])
        count_black.append(count_black[i-1]+1)

print(count_white)
print(count_black)
tmp = 0
for i in range(1, N):
    min_sum = 0
    min_sum += count_black[i]
    min_sum += (count_white[N-1] - count_white[i])
    tmp = min(tmp, min_sum)

print(tmp)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = str(input())
# '.'の場合は白, '#'の場合は黒

if S[0] == '.':
    count_white = [1]
    count_black = [0]
else:
    count_white = [0]
    count_black = [1]


for i in range(1, N):
    if S[i] == '.':
        # 見ている石が白なら
        count_white.append(count_white[i-1]+1)
        count_black.append(count_black[i-1])
    else:
        # 見ている石が黒なら
        count_white.append(count_white[i-1])
        count_black.append(count_black[i-1]+1)

print(count_white)
print(count_black)
tmp = 0
for i in range(1, N):
    min_sum = 0
    min_sum += count_black[i-1]
    min_sum += (count_white[N-1] - count_white[i-1])
    tmp = min(tmp, min_sum)

print(tmp)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = str(input())
# '.'の場合は白, '#'の場合は黒

if S[0] == '.':
    count_white = [1]
    count_black = [0]
else:
    count_white = [0]
    count_black = [1]


for i in range(1, N):
    if S[i] == '.':
        # 見ている石が白なら
        count_white.append(count_white[i-1]+1)
        count_black.append(count_black[i-1])
    else:
        # 見ている石が黒なら
        count_white.append(count_white[i-1])
        count_black.append(count_black[i-1]+1)

# print(count_black)
# print(count_white)

# change_count = [x+y for x, y in zip(count_white, count_black)]
tmp = 0
for i in range(1, N):
    min_sum = 0
    min_sum += count_black[i-1]
    min_sum += (count_white[N-1] - count_white[i])
    tmp = min(tmp, min_sum)

print(tmp)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = str(input())
# '.'の場合は白, '#'の場合は黒

if S[0] == '.':
    count_white = [1]
    count_black = [0]
else:
    count_white = [0]
    count_black = [1]


for i in range(1, N):
    if S[i] == '.':
        # 見ている石が白なら
        count_white.append(count_white[i-1]+1)
        count_black.append(count_black[i-1])
    else:
        # 見ている石が黒なら
        count_white.append(count_white[i-1])
        count_black.append(count_black[i-1]+1)

# print(count_black)
# print(count_white)

# change_count = [x+y for x, y in zip(count_white, count_black)]
tmp = 0
for i in range(N):
    min_sum = 0
    min_sum += count_black[i]
    min_sum += (count_white[N-1] - count_white[i])
    tmp = min(tmp, min_sum)

print(tmp)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = str(input())
# '.'の場合は白, '#'の場合は黒

if S[0] == '.':
    count_white = [1]
    count_black = [0]
else:
    count_white = [0]
    count_black = [1]


for i in range(1, N):
    if S[i] == '.':
        # 見ている石が白なら
        count_white.append(count_white[i-1]+1)
        count_black.append(count_black[i-1])
    else:
        # 見ている石が黒なら
        count_white.append(count_white[i-1])
        count_black.append(count_black[i-1]+1)

# print(count_black)
# print(count_white)

# change_count = [x+y for x, y in zip(count_white, count_black)]
tmp = 0
for i in range(1, N):
    min_sum = 0
    min_sum += count_black[i]
    min_sum += (count_white[N-1] - count_white[i])
    tmp = min(tmp, min_sum)

print(tmp)

Submission status: Wrong Answer

Solution code:
_ = input()
S = list(input())

c = 0
flag = False
for s in S:
    if s == '#':
        flag = True
    elif s == '.' and flag:
        c += 1
print(c)

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
s = input()

if all(c == s[0] for c in s):
    print(n)
    sys.exit()

cnt = 0
c_prev = s[0]
for c in s:
    if c_prev == '#' and c == '.':
        c_prev = '#'
        cnt += 1
    else:
        c_prev = c
print(cnt if cnt != 0 else n)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
N=int(input())
S=input()
w=S.count('.');c=w
for i in range(N):
  if S[i]=='.':
    c-=1
  else:
    c+=1
  c=min(c,w)
print(c)

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
s = input()

if all(c == s[0] for c in s):
    print(n)
    sys.exit()

cnt = 0
c_prev = s[0]
t = ""
for i, c in enumerate(s):
    if c_prev == '#' and c == '.':
        c_prev = '#'
        cnt += 1
    else:
        c_prev = c
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
s = input()

if all(c == s[0] for c in s):
    print(n)
    sys.exit()

cnt = 0
c_prev = s[0]
t = ""
for i, c in enumerate(s):
    if c_prev == '#' and c == '.':
        t += "#"
        cnt += 1
    else:
        t += c
    c_prev = c

# print(s)
# print(t)
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
 
arr = [0] if S[0] == "." else []
count = 0
for i in range(len(S)):
  count += 1
  if S[i:i+2] == "#.":
    arr.append(count)
    count = 0  
  if S[i:i+2] == ".#":
    arr.append(count)
    count = 0
arr.append(count)
#print(arr)
 
result = sum([min(arr[i:i+2]) for i in range(0, len(arr), 2)])
print(result)