problem_id
stringclasses
100 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
6
806
p02597
s639825566
Wrong Answer
N=int(input()) c=input() r=c.count("R") w=c.count("W") if w==0 or r==0: print(0) else: ans=w cnt=0 for i in range(N-1,N-w,-1): cnt+=(c[i]=="W") test=N-i-cnt+(w-cnt-(N-i-cnt)) ans=min(ans,test) print(ans)
p02597
s479018853
Wrong Answer
def q4(): n = int(input()) line = input() if 'WR' in line: r = line.count('R') safe = line[0:r-1].count('R') else: r = 0 safe = 0 print(r-safe) if __name__ == "__main__": q4()
p02597
s414939807
Wrong Answer
n = int(input()) c = list(input()) w = 0 r = c.count("R") ans = n for i in range(n) : if c[i] == "W" : w += 1 else : r -= 1 if ans > max(w,r) : ans = max(w,r) print(ans)
p02597
s396055185
Wrong Answer
# coding: utf-8 # Your code here! N=int(input()) S=list(input()) print(S[:N//2].count("W"))
p02597
s249841334
Wrong Answer
n=int(input()) s=input() a=[] r,w=0,0 ans=float("inf") for i in range(n): if s[i]=="R": r+=1 else: w+=1 a.append([r,w]) for i in range(n): r1,w1=a[i][0],a[i][1] r2,w2=r-r1,w-w1 t=min(w1,r2) tmp=t+max(w1-t,0)+max(r2-t,0) if tmp<ans: ans=tmp print(ans)
p02597
s842752711
Wrong Answer
n = int(input()) al = list(input()) cr = al.count('R') cw = al.count('W') if cr == 0 or cw == 0: print(0) exit() def ceil(a, b): return -(-a // b) ans = 0 cr = cr // 2 + 1 for a in al[::-1]: if a == 'W': cr -= 1 ans += 1 if cr == 0: break print(ans)
p02597
s639795052
Wrong Answer
import math N= int(input()) c=list(str(input())) #N=4 #c=['W', 'W', 'R', 'R'] #c.reverse() print(c) num=0 for i in reversed(range(N)): if c[i]=='R' : for u in (range(num,i)): if c[u]=='W': c[u]='y' c[i]='W' num+=1 break print(c) print(num)
p02597
s972093153
Wrong Answer
k = int(input()) s = input() if len(set(s)) == 1: print(0) exit() left_r = s[:k//2].count('R') left_w = (k//2) - left_r right_r = s[k//2:].count('R') right_w = (k//2) - right_r res = min(left_w, right_r) if right_r and not left_w and (k % 2 and s[k//2] == 'W'):res+=1 print(res)
p02597
s163331921
Wrong Answer
N = int(input()) C = input() count = 0 r = 0 w = 0 for i in range(N // 2): c = C[i] if c == "W": if r > 0: r -= 1 count += 1 else: w += 1 c = C[N-i-1] if c == "R": if w > 0: w -= 1 count += 1 else: r += 1 ans = count + w print(ans)
p02597
s237996484
Wrong Answer
n = int(input()) cs = input() cand1 = cs[:cs.count('R')].count('W') cand2 = cs[cs.count('W'):].count('R') if cand1 > cand2: print(min(cand1, cand2)) else: print(max(cand1, cand2))
p02597
s875002120
Wrong Answer
n=int(input()) c=input() n_R=c.count('R') n_W=0 temp=n_R ans=1000000007 for i in range(n): if c[i]=='W': n_W+=1 else: n_R-=1 temp=max(n_W,n_R) ans=min(temp,ans) print(ans)
p02597
s108302684
Wrong Answer
n = int(input()) c = list(input()) count = 0 for i in range(n//2): if c[n-1-i] == 'R': for j in range(n//2): if c[j] == 'W': c[i] = 'W' c[j] = 'R' count += 1 break print(count)
p02597
s259623463
Wrong Answer
N = int(input()) C = list(input()) N1 = int(N/2) C1 = C[0:N1] C2 = C[N1:N] count = 0 if (C1.count('W') == 0 and C1.count('R') == 0 and C2.count('W') == 0 and C2.count('R') == 0): count = 0 elif (C1.count('W') == C2.count('R')): #左右対象のとき count = C1.count('W') elif(C1.count('R') == C2.count('W')): count = C.count('W') else: if(C.count('W') > C.count('R')): count = C.count('R') else: count = C.count('W') print(count)
p02597
s564536593
Wrong Answer
def solve(): n = int(input()) c = input() x = c.count('R') if x == n or x == 0: return 0 w1 = 0 for i in range(n): if c[i] == 'W': w1 += 1 else: break return max(x-1, w1) print(solve())
p02597
s008538025
Wrong Answer
n = int(input()) c = input() w = 0 r = c.count('R') ans = n for i in c: if i == 'W': w += 1 else: r -= 1 ans = min(ans, max(w, r)) print(ans)
p02597
s933289948
Wrong Answer
N = int(input()) c= list(input()) if c.count('R') == N: print(0) exit() div=0 if N %2 == 1: div =1 clist_L = c[:int(N/2)] clist_R = c[int(N/2)+div:] Lcnt = clist_L.count('W') Rcnt = clist_R.count('R') if Lcnt - Rcnt <=0: print(Rcnt) else: print(Lcnt-Rcnt)
p02597
s666346519
Wrong Answer
n=int(input()) s=input() print(max(s[:n//2].count('W'),s[n//2:].count('W')))
p02597
s965050462
Wrong Answer
n=int(input()) s=input() l,r=0,n-1 ans=0 while r>l: while l<n and s[l]=="R": l+=1 while r>0 and s[r]=="W": r-=1 if l<n and r>0 and s[l]=="W" and s[r]=="R": ans+=1 l+=1 r-=1 print(ans)
p02597
s782059063
Wrong Answer
n = int(input()) c = input() left, right = 0, n - 1 cnt = 0 while left <= right: while left < n and c[left] == 'R': left += 1 while right > -1 and c[right] == 'W': right -= 1 if left == n or right == -1: break left += 1 right -= 1 cnt += 1 print(cnt)
p02597
s788009928
Wrong Answer
n=int(input()) c=list(input()) r=[] w=[] for i in range(n): if c[i]=='R': r.append(i) else: w.append(i) w.reverse() ans=0 for i in range(min(len(r),len(w))): if r[i]>w[i]: ans+=1 print(ans)
p02597
s314572623
Wrong Answer
#! /usr/bin/env python3 # from math import gcd from fractions import gcd from collections import Counter, deque, defaultdict from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort from itertools import accumulate, product, permutations, combinations, combinations_with_replacement N = int(input()) c = input() L = Counter(c[:N//2]) R = Counter(c[N//2:]) if "W" not in c: print(0) exit() ct = min(L["W"], R["R"]) if L["W"] < R["R"]: ct += R["R"] - L["W"] A = Counter(c) print(min(A["W"], A["R"], ct))
p02597
s499302777
Wrong Answer
N=int(input()) c=list(input()) minimum=len(c) W=0 R=c.count('R') for i in range(0,len(c)): if c[i]=='W': W += 1 else : R -= 1 min_i=max(W,R) if min_i < minimum: minimum=min_i print(minimum)
p02597
s449299088
Wrong Answer
def main(): n = int(input()) li = list(input()) i = 0 j = n-1 ans = 0 while(i < j): while(li[i] == "R" and i < j): i += 1 while(li[j] == "W" and i < j): j -= 1 if li[i] == "W" and li[j] == "R": li[i] = "R" li[j] = "W" ans += 1 print(li) print(ans) if __name__ == '__main__': main()
p02597
s101728117
Wrong Answer
from bisect import bisect_right as br n = int(input()) c = list(input()) cFixed = [x for x in c] cFixed.sort() for i in range(n): if cFixed[i] == "R": lastR = i ans = 0 for i in range(n): if c[i] != cFixed[i]: j = br(c,"R", lo = lastR + 1)-1 #print(j,i,c[j],c[i],cFixed[i]) c[i] = c[j] c[j] = "W" ans += 1 print(ans)
p02597
s547964933
Wrong Answer
s = int(input()) n = input() str_list = list(n) w_cnt = str_list.count('W') r_cnt = str_list.count('R') if w_cnt == 0 or r_cnt == 0: print(0) else: w_result = str_list[w_cnt:] r_result = str_list[:r_cnt] r = w_result.count('R') w = r_result.count('W') if w <= r: print(r) else: print(w)
p02597
s398904138
Wrong Answer
n=int(input()) a=list(input()) # あかのインデックス RR=[-1] # しろのインデックス WW=[] for i in range(n): if a[i]=='R': RR.append(i) else: WW.append(i) WW.append(float('inf')) if a.count('R')==0 or a.count('R')==n: print(0) exit() for i in range(len(RR)-1): if RR[-2-i]<WW[i+1]: print(i+1) exit()
p02597
s129767514
Wrong Answer
N = int(input()) S = input() wl = 0 for i in range(N): if S[i] == "W": wl += 1 rl = N - wl l = 0 if N % 2 == 0: for i in range(N//2): if S[i] == "W": l += 1 else: for i in range(N//2+1): if S[i] == "W": l += 1 print(min([wl, rl, l]))
p02597
s517021174
Wrong Answer
N=int(input()) C=input() from collections import Counter count=Counter(C) #print(count) countR=count["R"] countW=count["W"] missR=0 missW=0 for i in range(N): now=C[i] if now=="W" and i<countW: missW+=1 if now=="R" and i>=N-countR: missR+=1 # print(countR, countW) X=min(missW, missR) if X!=0: ans=min(missW, missR)+abs(missR-missW) else: ans=0 print(ans)
p02597
s953893404
Wrong Answer
n = int(input()) c = input() sumr_ = 0 for _ in c: sumr_ += (_ == "R") if sumr_ == len(c) or sumr_ == 0: print(0) quit() sumr = sumr_ sumc = 0 minc = 10**8 for i in range(len(c)): if c[i] == "R": sumc += i sumr -= 1 minc = min(sumr_, sumc + sumr) print(minc)
p02597
s785209365
Wrong Answer
n=int(input()) s=input() if s.count('R')==0 or s.count('W')==0: print(0) else: w=s.index('W') i=w while(i<len(s) and s[i]=='W'): i+=1 a= i-w+1 if i==len(s): print(0) else: b=s[i:].count('R') if a<b: b-=1 print(min(s.count("W"),b))
p02597
s117210250
Wrong Answer
n = int(input()) l = list(input()) num1 = l.count('R') num2 = 0 i = 0 A = True for i in range(num1): if l[i] != 'R': A = False if num1 == 0 or A == True: print(0) else: while l[i] != 'R': num2 += 1 i += 1 if num2 <= num1 - 1: print(num1 - 1) else: print(num1)
p02597
s338969568
Wrong Answer
N = int(input()) C = list(input()) count = 0 for i in range(int(N/2)): if C[N-i-1] == 'R': for j in range(N-i-1): if C[j] == 'W': C[N-i-1] = 'W' C[j] = 'R' count += 1 break print(count)
p02597
s290032379
Wrong Answer
N = int(input()) data = input() intdata = [] ans = 0 for d in data: if d == "R": intdata.append(0) else: intdata.append(1) sortdata = sorted(intdata) if len(intdata) % 2 == 0: amari = 0 else: amari = 1 for i in range(int(len(intdata)/2) + amari): if intdata[i] != sortdata[i]: ans += 1 if len(intdata) % 2 == 1: print(ans-1) else: print(ans)
p02597
s488192144
Wrong Answer
import math N= int(input()) c=list(str(input())) #N=4 #c=['W', 'W', 'R', 'R'] #c.reverse() #print(c) num=0 for i in reversed(range(math.ceil(N/2),N)): if c[i]=='R' : for u in (range(N)): if c[u]=='W': c[u]='y' c[i]='W' num+=1 break #print(c) print(num)
p02597
s384209604
Wrong Answer
N = int(input()) C = input() ans = 0 w = C.count("W") r = C.count("R") if w <= r: print(C[0:w].count("W")) else: print(C[w:len(C)].count("R"))
p02597
s142784622
Wrong Answer
N = int(input()) C = list(input()) N1 = int(N/2) C1 = C[0:N1] C2 = C[N1:N] count = 0 if (C1.count('W') == C2.count('R')): #左右対象のとき count = C1.count('W') else: count = C.count('W') print(count)
p02597
s328882759
Wrong Answer
N = int(input()) C = input() W = C.count("W") R = N-W counter = 0 if(W<R): wrong = C[:W-1].count("W") print(wrong) else: wrong = C[W-1:].count("R") print(wrong)
p02597
s042061410
Wrong Answer
n=int(input()) c=list(input()) lw_cnt=0 rw_cnt=0 rr_cnt=0 flg=-1 for i in range(n): if flg<0 and c[i]=='W': lw_cnt+=1 elif flg<0 and c[i]=='R': flg=i elif flg>=0 and c[i]=='R': rr_cnt+=1 else: rw_cnt=1 print(max(lw_cnt,rw_cnt*rr_cnt))
p02597
s182887240
Wrong Answer
n = int(input()) a = input() red = 0 for i in range(n): if a[i] == 'R': red += 1 ans = 0 for i in range(n-red): if a[i] == 'W': ans += 1 print(ans)
p02597
s904951518
Wrong Answer
n = int(input()) c = input() ans = 0 for v in c[: n // 2]: if v == "W": ans += 1 print(ans)
p02597
s008437695
Wrong Answer
N=int(input()) C=input() from collections import Counter count=Counter(C) #print(count) countR=count["R"] countW=count["W"] missR=0 missW=0 for i in range(N): now=C[i] if now=="W" and i>=N-countW: missW+=1 if now=="R" and i<countR: missR+=1 # print(countR, countW) X=min(missW, missR) if X!=0: ans=min(missW, missR)+abs(missR-missW) else: ans=0 print(ans)
p02597
s667817210
Wrong Answer
n = int(input()) s = [_ for _ in input()] l, r = 0, n-1 if not('R' in s): print(0) exit() if not('W' in s): print('0') exit() ans = 0 while 1: while s[l] == 'W': l += 1 while s[r] == 'R' and l < r: r -= 1 ans += 1 if l >= r: break l += 1 r -= 1 print(ans)
p02597
s412889066
Wrong Answer
N = int(input()) A =input() if N % 2 == 0: k = N // 2 B = A[0:k] #print(B) print(B.count("W")) else: kk = N // 2 B = A[0:kk+1] #print(B) print(B.count("W"))
p02597
s429002439
Wrong Answer
import numpy as np N=int(input()) C=np.array([x for x in input()]) if N%2==0: print(np.count_nonzero(C[:N//2]=='W')) else: print(np.count_nonzero(C[:N//2+1]=='W'))
p02597
s416792761
Wrong Answer
n = int(input()) c = input() c = c.lstrip('R') c = c.rstrip('W') n = len(c) rn = c.count('R') if n == 0: print(0) else: print(min(c[:rn].count('W'),c[n-rn:].count('R')))
p02597
s413097437
Wrong Answer
N=int(input()) white=0 red=0 W=list(str(input())) if "W" not in W or "R" not in W: print("0") exit() for i in range(N//2): if W[i]=="W": white+=1 for i in range(N//2): if W[N-1-i]=="R": red+=1 if white>=red: print(red) else: Z=white*2-red if (N/2)%1!=0: if W[N//2+1]=="W" and W[N//2+2]=="R": Z+=1 print(Z)
p02597
s192720828
Wrong Answer
n = int(input()) c = input() # 1文字ずつのListに変換 list_c = ','.join(map(lambda x: '"{}"'.format(x), list(c))) print(list_c) all_change = 0 if list_c.count('W') < list_c.count('R') : all_change = list_c.count('W') else : all_change = list_c.count('R') print(all_change)
p02597
s310097391
Wrong Answer
n=int(input()) s=list(input()) count_w = 0 w_list = [] r_list = [] for i in range(n): if s[i] == 'W': count_w += 1 w_list.append(i) else: r_list.append(i) w_list.reverse() chage_count = 0 while len(w_list) > 0 and len(r_list) > 0 and r_list[-1] > w_list[-1]: r_list.pop() w_list.pop() chage_count += 1 if len(w_list) > 0 and len(r_list) == 0: chage_count += len(w_list) print(min(chage_count, count_w))
p02597
s853097358
Wrong Answer
import sys N = int(input()) c = input() n = int(N/2) c_1 = c[:n] print(c_1.count('W'))
p02597
s038908639
Wrong Answer
n = int(input()) c = list(input()) r = 0 cnt = 0 for i in range(n): if c[i] == "R" : r += 1 else : cnt = i break print(c.count("R")-r)
p02597
s609814905
Wrong Answer
import math N= int(input()) c=list(str(input())) #N=4 #c=['W', 'W', 'R', 'R'] #c.reverse() #print(c) num=0 for i in reversed(range(N)): if c[i]=='R' : for u in (range(N-i-1)): if c[u]=='W': c[u]='y' c[i]='W' num+=1 break #print(c) print(num)
p02597
s684175998
Wrong Answer
ni = lambda: int(input()) nm = lambda: map(int, input().split()) nl = lambda: list(map(int, input().split())) n=ni() c = [1 if _ == 'R' else 0 for _ in input()] b = n-sum(c) w=0 r=0 for i in range(n): if c[i] == 0 and i <= b: w+=1 if c[i] == 1 and i > b: r+=1 print(max(w,r))
p02597
s309696730
Wrong Answer
import sys from itertools import groupby def input(): return sys.stdin.readline().rstrip() def main(): n=int(input()) c=list(input())[::-1] ans=0 red=0 for key, value in groupby(c): if key=='R': red=len(list(value)) else: ans+=min(red,len(list(value))) print(ans) if __name__=='__main__': main()
p02597
s642262043
Wrong Answer
n = int(input()) c = input() count = 0 for i in range(n//2 + 1): if 'W' == c[i]: count += 1 print(count)
p02597
s989588950
Wrong Answer
N = int(input()) c = list(input()) num_r = 0 for ci in c: if ci == 'R': num_r += 1 ans = 0 if num_r != N and num_r != 0: for i in range(num_r+1): if c[i] == 'W': ans += 1 print(ans)
p02597
s592328157
Wrong Answer
N = int(input()) C = input() ans = 0 w = 0 r = 0 for i in range(N // 2): if C[i] == "W": if r > 0: r -= 1 ans += 1 else: w += 1 j = N - i - 1 if C[j] == "R": if w > 0: w -= 1 ans += 1 else: r += 1 ans += w print(ans)
p02597
s442590707
Wrong Answer
n=(int)(input()) a=input().split() sum_red=0 for i in a: if i=="R": sum_red+=1 sum=0 for i in range(sum_red): if a[i]=="W": sum+=1 print(sum)
p02597
s844691671
Wrong Answer
import sys sys.setrecursionlimit(10**6) read = sys.stdin.read readlines = sys.stdin.readlines def main(): n = int(input()) a = input() if not 'WR' in a: print(0) else: rightmostW = a.find('WR') wnum = a[rightmostW+2:].count('R') leftmostR = a.rfind('R') wnum2 = a[:leftmostR].count('W') r = min(wnum, wnum2) print(r) if __name__ == '__main__': main()
p02597
s140175359
Wrong Answer
N = int(input()) S = input() ans = 0 cnt = [0, 0] for i in range(N): if S[i] == "W": if i > 0 and S[i - 1] == "R": ans += min(cnt) cnt = [0, 0] cnt[0] += 1 else: cnt[1] += 1 ans += min(cnt) print(ans)
p02597
s799999785
Wrong Answer
n = int(input()) c = input() r = 0 w = 0 l = 0 ans = 0 for i in range(n): if c[i] == "W": w += 1 else: r += 1 if i < n / 2: l += 1 if r == 0 or w == 0: print(0) exit() elif w < r: ans += r - w r = w ans += r - l if ans <= w: print(ans) else: print(w)
p02597
s562629349
Wrong Answer
n = int(input()) c = list(input()) counter = 0 k = 0 i = 0 j = n-1 while i <= j: if c[i] == 'W' and c[j] == 'R': counter += 1 i += 1 j -= 1 else: j -= 1 print(counter)
p02597
s071996862
Wrong Answer
#D - Alter Altar / N = int(input()) C =[] C = list(map(str,input())) total = 0 write_ko = len(list(filter(lambda x :x == 'W',C))) red_ko = N - write_ko for i in range(N): for j in range(N-1,1,-1): if (C[i] == 'W') and (C[j] == 'R'): if (i < j): C[i] = 'G' C[j] = 'B' total += 1 # 出力 print(total)
p02597
s580445582
Wrong Answer
n = int(input()) c = input() h1 = (n + 1) // 2 h2 = n // 2 ans1 = min(c[:h1].count('W'), c[h1:].count('R')) ans2 = min(c[:h2].count('W'), c[h2:].count('R')) print(min(ans1, ans2))
p02597
s120812721
Wrong Answer
n=int(input()) c=list(input()) lw_cnt=0 rr_cnt=0 flg=-1 for i in range(n): if flg<0 and c[i]=='W': lw_cnt+=1 elif flg<0 and c[i]=='R': flg=i elif flg>=0 and c[i]=='R': rr_cnt+=1 else: rw_cnt=1 if lw_cnt==0 or rr_cnt==0: print(0) else: print(max(lw_cnt,rr_cnt))
p02597
s027974669
Wrong Answer
import collections def main(): N = int(input()) S = list(input()) if len(set(S))==1: print(0) return cnt = 0 left = 0 right = len(S)-1 while left<right: if S[left] == 'W': cnt +=1 left += 1 right -=1 while left<len(S) and S[left]=='R': left += 1 print(cnt) return 0 if __name__ == "__main__": main()
p02597
s666026332
Wrong Answer
import sys input = sys.stdin.readline n = int(input()) n2 = n//2 c = input() if c.count("R") == n: print(0) elif c.count("W") == n: print(0) elif n%2 == 0: cnt = c.count("R", n2, n) print(cnt) else: cnt = c.count("R", n2+1, n) print(cnt)
p02597
s057419927
Wrong Answer
def ii():return int(input()) def iim():return map(int,input().split()) def iil():return list(map(int,input().split())) from collections import Counter n = ii() s = input() d = Counter(s) num = d['R'] ans = num wcnt = 0 rcnt = 0 for i in s: if i == 'W': wcnt += 1 else: if num - 1 > wcnt or wcnt == 0: ans -= 1 num -= wcnt wcnt = 0 else: break print(ans)
p02597
s849877973
Wrong Answer
import sys import math import itertools import collections import heapq import re import numpy as np from functools import reduce rr = lambda: sys.stdin.readline().rstrip() rs = lambda: sys.stdin.readline().split() ri = lambda: int(sys.stdin.readline()) rm = lambda: map(int, sys.stdin.readline().split()) rl = lambda: list(map(int, sys.stdin.readline().split())) inf = float('inf') mod = 10**9 + 7 n = ri() s = rr() cnt = 0 while 'WR' in s: cnt += s.count('WR') s = s.replace('WR', '') print(cnt)
p02597
s603032200
Wrong Answer
k = int(input()) s = input() most_left_r = 0 r_cnt_r = 0 r_cnt_w = 0 l_cnt_w = 0 res = 0 for i in range(len(s)): if s[i] == "R": most_left_r = i break for j in range(most_left_r+1, len(s)): if s[j] == "R": r_cnt_r+=1 else: r_cnt_w+=1 for k in range(0, most_left_r): if s[k] == "W": l_cnt_w += 1 res = max((min(r_cnt_r, r_cnt_w)), l_cnt_w) print(res)
p02597
s191576411
Wrong Answer
import math N = int(input()) str = input() A = list(str) X = math.floor(N/2) count = 0 for i in range(0,X+1): if A[i] == "R": count = count +1 else: pass print (X-count)
p02597
s104393595
Wrong Answer
import math N= int(input()) c=list(str(input())) #N=4 #c=['W', 'W', 'R', 'R'] c.reverse() #print(c) num=0 for i in range(N): if c[i]=='R' : for u in reversed(range(math.ceil(N/2),N)): if c[u]=='W': c[u]='y' c[i]='W' num+=1 break #print(c) print(num)
p02597
s331986029
Wrong Answer
k = int(input()) L = list(input()) ans = 0 w = 0 r = 0 for i in range(1, k): if i <= k//2 and L[i] == "W": w += 1 if i >= k//2 and L[i] == "R": r += 1 ans = (w + r)//2 + 1 if "W" not in L: ans = 0 if "R" not in L: ans = 0 print(ans)
p02597
s301686718
Wrong Answer
n = int(input()) s = input() w = s.count('W') print(s[-w:].count('R'))
p02597
s795097252
Wrong Answer
N = input() li = input() #print(li) red = li.count("R") white = li.count("W") if red >= white: target = li[-1*white:] ans = white - target.count("W") print(ans) else: print(red)
p02597
s193296900
Wrong Answer
n = int(input()) cn = input() cn = list(cn) w_total = sum(1 for i, c in enumerate(cn) if cn[i] == 'W') w = 0 mn = 10**9 for i, c in enumerate(cn, 1): if c == 'W': w += 1 r = (len(cn) - i) - (w_total - w) m = max(r, w) mn = min(mn, m) print(mn)
p02597
s231361992
Wrong Answer
def change(S,index,color): lstS = list(S) lstS[index] = color S = ''.join(lstS) return S if __name__ == '__main__': N = int(input()) S = input() L = 0 R = N-1 count = 0 if S.count('W') == 0 or S.count('R') == 0: R = -1 while(L < R): while(S[L] == 'R'): L += 1 while(S[R] == 'W'): R -= 1 S = change(S,L,'R') S = change(S,R,'W') L += 1 R -= 1 count += 1 print(count)
p02597
s156293620
Wrong Answer
i=int(input()) s=list(input()) fw,fr=0,0 count=0 cw=0 cr=0 if s[0]=="W" and s[i-1]=="R": count+=1 s[0]="R" s[i-1]="W" if s[i-1]=="R": count+=1 s[i-1]="W" for j in range (i): if s[j]=="W" : fw=j cw+=1 break print (s) for j in range (fw+1,i): if s[j]=="R": count+=1 print(count)
p02597
s246120321
Wrong Answer
# alter altar length = int(input()) stone = input() red = [0] * (length + 1) white = [0] * (length + 1) [red_num, white_num] = [0, 0] for i in range(1, length + 1): if(stone[i-1] == "W"): white_num += 1 if(stone[length-i] == "R"): red_num += 1 white[i] = white_num red[length - i] = red_num # print(white) # print(red) mini = 200000 for i in range(1, length+1): trial = max(white[i], red[i]) mini = min(mini, trial) print(mini)
p02597
s113769929
Wrong Answer
n=int(input()) s=input() l,r=0,n-1 ans=0 while l<r: cnt=0 while r>=0 and s[r]=='W':r-=1 while l<n and s[l]=='R':l+=1 if l>=r:break while s[r]=='R': cnt+=1 r-=1 cm=cnt while cnt: if s[l]=='W':cnt-=1 l+=1 if l>=r:break if cnt>0:ans+=cnt else:ans+=abs(cm-cnt) print(ans)
p02597
s899794289
Wrong Answer
N = int(input()) c = list(input()) ans = 0 FLG = False for i in range(N): if c[i] == "W": j = N - 1 while c[j] == "W": j -= 1 if j == i: FLG = True break if FLG: break ans += 1 c[i], c[j] = c[j], c[i] print(ans)
p02597
s869294615
Wrong Answer
N = int(input()) C=list(input()) X=0 Y=0 print(C) for i in range(N): if C[i]=='W': for ii in range(Y, N-i-Y): if C[N-1-ii]=='R': C[i]='R' C[N-1-ii]='W' X=X+1 print(C) Y=ii break if i+Y==N-2: break print(X)
p02597
s015403799
Wrong Answer
N = int(input()) S = input() count = 0 while True: if S.count('R') == 0: break if S[0] == 'R': S=S.lstrip('R') else: Rposfirst=S.find('R') Rposend = S.rfind('R') S = S[Rposfirst:Rposend] count += Rposfirst print(count)
p02597
s227778536
Wrong Answer
N = int(input()) C = input() ans = 0 w = C.count("W") r = C.count("R") print(C[0:w].count("W"))
p02597
s470086262
Wrong Answer
import math def resolve(): N=int(input()) C=input() target = 'WR' index = -1 cnt=0 Rf=C[:N//2].count('R') Rr=C[N//2+1:].count('R') Wf=C[:N//2].count('W') Wr=C[N//2+1:].count('W') if(N%2==0): Centor="" else: Centor=C[N//2:N//2+1] cnt+=max(Wf,Rr) if(C.count('R')==0 or C.count('W')==0): cnt=0 print(cnt) resolve()
p02597
s561452396
Wrong Answer
N = int(input()) c = input() if 'R' not in c: print(0) exit() first_R = c.index('R') num_R = c.count('R') if first_R>num_R: print(num_R) else: print(first_R+c[first_R:first_R+num_R].count('W'))
p02597
s109163346
Wrong Answer
n = int(input()) k = input() k2 = k[::-1] i1 = 0 i2 = 0 cnt = 0 while i1 < n: if k[i1] == 'W': while i2 < n: if k2[i2] == 'R': k2 = k2[:i2] + 'W' + k2[i2+1:] cnt += 1 break i2 += 1 i1 += 1 if i1 + i2 >= n: break print(cnt)
p02597
s521944461
Wrong Answer
N=int(input()) c=input() if N%2==0: print(max(c[:N//2].count('W'),c[N//2:].count('R'))) else: print((max(c[:(N-1)//2].count('W'),c[(N-1)//2:].count('R'))))
p02597
s678150697
Wrong Answer
N = int(input()) data = input() intdata = [] ans = 0 for d in data: if d == "R": intdata.append(0) else: intdata.append(1) sortdata = sorted(intdata) if len(intdata) % 2 == 0: amari = 0 else: amari = 1 for i in range(int(len(intdata)/2)): if intdata[i] != sortdata[i]: ans += 1 print(ans)
p02597
s052781874
Wrong Answer
n = int(input()) c = input() p,q = 0,n-1 x = 0 while(p<q): while(c[p] == 'R' and p < n-1): p += 1 while(c[q] == 'W' and q > 0): q -= 1 if(p < n-1 and q > 0): p += 1 q -= 1 x += 1 else: break print(x)
p02597
s564940938
Wrong Answer
N = int(input()) c = list(input()) pre = c[0:N//2] suf = c[(N+1)//2:N] mid = c[N//2] if N % 2 != 0 else 'F' ans = 0 pre_cnt = pre.count('W') suf_cnt = suf.count('R') ans = min(pre_cnt,suf_cnt) if mid == 'W' and suf_cnt-pre_cnt > 0: ans+=1 elif mid == 'R' and pre_cnt-suf_cnt > 0: ans+=1 print(ans)
p02597
s263822687
Wrong Answer
n = int(input()) s = [_ for _ in input()] l, r = 0, n-1 if not('R' in s): print(0) exit() if not('W' in s): print('0') exit() ans = 0 while 1: while s[l] == 'R': l += 1 while s[r] == 'R' and l < r: r -= 1 ans += 1 if l >= r: break l += 1 r -= 1 print(ans)
p02597
s953172097
Wrong Answer
N=int(input()) c=input() mid=N//2 if N%2==0: rl=c[mid:].count('R') wf=c[:mid].count('W') else: rl=c[mid:].count('R') wf=c[:mid+1].count('W') print(min(rl,wf))
p02597
s816828035
Wrong Answer
import math N = int(input()) c = list(input()) count_W = 0 for i in range(math.ceil(N/2)): if c[i] == 'W': count_W += 1 count_R = 0 for i in range(math.ceil(N/2)): if c[-1-i] == 'R': count_R += 1 print(min(count_R, count_W))
p02597
s641451652
Wrong Answer
n = int(input()) c = list(input()) c2 = c[::-1] cou = 0 for i in range(len(c)//2): if c2[i] == "R": cou += 1 for i in range(len(c)//2): if c[i] == "W": if c[i+1] == "R": cou += 1 print(cou)
p02597
s541402929
Wrong Answer
N = int(input()) stones = input() count_R = stones.count('R') if N == count_R: answer = 0 elif N - count_R > count_R: answer = count_R else: answer = count_R - 1 print(answer)
p02597
s055138241
Wrong Answer
N=int(input()) C=input() from collections import Counter count=Counter(C) #print(count) countR=count["R"] countW=count["W"] missR=0 missW=0 for i in range(N): now=C[i] if now=="W" and i<N-countW: missW+=1 if now=="R" and i>=N-countR: missR+=1 # print(countR, countW) X=min(missW, missR) ans=min(missW, missR)+abs(missR-missW) print(ans)
p02597
s139994823
Wrong Answer
N = int(input()) c = list(input()) pre = c[0:N//2] suf = c[N//2:N] ans = 0 pre_cnt = pre.count('W') suf_cnt = suf.count('R') ans = pre_cnt and suf_cnt print(ans)
p02597
s517461469
Wrong Answer
k = int(input()) m = 7%k ans = 1 jud = True p = 70%k for i in range(k): m = (m + p)%k ans += 1 if m == 0: break p = p*10%k if p == 0: jud = False break if jud: print(ans) else: print(-1)
p02597
s893303517
Wrong Answer
import sys def I(): return int(sys.stdin.readline().rstrip()) def S(): return sys.stdin.readline().rstrip() N = I() c = S() ans = 0 if set(c)==1: print(0) exit() temp1,temp2 = 0,N-1 while 1: if c[temp1]=='R': temp1 += 1 else: if c[temp2]=='W': temp2 -= 1 if temp1>=temp2: break ans += 1 temp1 += 1 temp2 -= 1 print(ans)
p02597
s503738034
Wrong Answer
n = int(input()) c = input() na = len(c) red = 0 whi = 0 cou_start = 0 cou = 0 for i in reversed(range(0,na)): if c[i] == "W": whi += 1 if cou_start == 1: cou += 1 else: red += 1 #print(red,whi,cou) if red >= 2 and whi >= 1: cou_start=1 pri = min(whi,red) if cou != 0: pri = min(cou,pri) print(pri)