problem_id
stringclasses
100 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
6
806
p02597
s217508213
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 print(ans)
p02597
s027768262
Wrong Answer
k=int(input()) n=0 a=0 ss=0 if k%7==0: print(1) elif k%2==0: print(-1) elif k%5==0: print(-1) else: while a==0 and n<=1000000: n+=1 ss=10*(ss%k)+1 if ss%k==0: a=1 if a==1: print(n) else: print(-1)
p02597
s469127162
Wrong Answer
def dist(s, r): wcount = 0 for i in range(r): wcount += (s[i] == "W") rcount = 0 for i in range(r, n): rcount += (s[i] == "R") return max(wcount, rcount) n = int(input()) s = input() minstep = n for i in range(n): minstep = min(dist(s, i), minstep) print(minstep)
p02597
s228604608
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: for i in range(num_r+1): if c[i] == 'W': ans += 1 print(ans)
p02597
s407748717
Wrong Answer
n = input() s = input() L = 0 r = len(s) cnt = 0 while True: L = s.find('W') if L == -1: break r = s.rfind('R') if r == -1: break if (L > r): break s = s[L + 1:r].lstrip('R').rstrip('L') cnt += 1 if L != -1 and L > r: cnt += L + 1 print(cnt)
p02597
s024678343
Wrong Answer
N = int(input()) S = input() count = N numW = S[:0].count('W') numR = S[0:].count('R') if(numW == N): print(0) else: for i in range(N): if(S[i] == 'W'): numW += 1 else: numR -= 1 if(max(numW, numR) < count): count = max(numW, numR) print(count)
p02597
s496886894
Wrong Answer
from collections import deque N = int(input()) C = deque(input()) ans = 0 while len(C)>1: a,b = C.popleft(), C.popleft() if b=="R" and a=="W": C.appendleft(b) ans += 1 C.appendleft(b) print(ans)
p02597
s071273896
Wrong Answer
N = int(input()) list=[] list = (str(input())) cnt = 0 R = 0 W = 0 ans = 0 for i in range (N): if list[i] == "R": R += 1 W = N-R cnt = min(R, W) if R > W: for i in range(cnt): if list[N-cnt-1]=="R": ans +=1 if R<=W: for j in range(cnt): if list[j] == "W": ans +=1 print(ans)
p02597
s834166036
Wrong Answer
from re import match n = int(input()) ci = input() if len(match('R*W*', ci).group(0)) == n: print(0) exit() fst = ci.find('R') rng = len(match('^R+', ci[fst:]).group(0)) Rs = ci.count('R') Ws = n - Rs ''' first <= Ws ''' Rs2 = Rs - fst Ws2 = Ws - fst if Rs2 == 0: print(fst) elif Ws2 == 0: print(Rs) else: print(fst + Rs2 - rng)
p02597
s504631931
Wrong Answer
N = input() # C = list(map(lambda x: x == 'W', list(input()))) C = list(input()) countR = 0 countI = 0 for n, c in enumerate(C): if countI == 0 and c == 'W' : countI = n if c == 'W' : countR += 1 RZ = len(C) - countI +1 RZW = RZ - countR if countR == 0 : RZW = 0 print(RZW)
p02597
s981454144
Wrong Answer
N = int(input()) mozi = input() mozi2 = list(mozi) a = len(mozi2) num_w = mozi2.count("W"); num_r = mozi2.count("R") list_w2 = mozi2[(a-num_w+1):]; list_w1 = mozi2[:(a-num_w+1)] list_r2 = mozi2[(a-num_r+1):]; list_r1 = mozi2[:(a-num_r+1)] if num_w >= num_r: if "W" in list_w2: print(list_w1.count("W")) else: print(num_w) else: if "R" in list_r1: print(list_r2.count("R")) else: print(num_r)
p02597
s859724511
Wrong Answer
N = int(input()) C = input() R, W = [], [] R_ = [] nR, nW = 0, 0 for c in C: if c == 'R': nR += 1 else: nW += 1 R.append(nR) W.append(nW) for r in R: R_.append(nR - r) #print(R) #print(W) #print(R_) ans = N for i in range(N): r, w, r_ = R[i], W[i], R_[i] if r_ > w: ans = min(r_, ans) else: ans = min(w, ans) print(ans)
p02597
s697700233
Wrong Answer
def checkFunction(c): count = 0 while True: if not ('WR' in c): return count while c[0] == 'R': c = c[1:] while c[-1] == 'W': c = c[:-1] if c.index('R') + 1 != len(c): c = c.replace('WR', 'RR',1)[:-1] count += 1 else: return count + 1 N = int(input()) c= input() print(checkFunction(c))
p02597
s179350043
Wrong Answer
N=int(input()) c=list(input()) c1=c[::-1] ans=0 w_index=[i for i, x in enumerate(c) if x=="W"] r_index=[i for i, x in enumerate(c1) if x=="R"] for i in range(len(r_index)): r_index[i]=N-1-r_index[i] if "R" in c and "W" in c: for i in range(min(len(r_index),len(w_index))): w=w_index[ans] r=r_index[ans] if w-r==1: ans=ans-1 break ans+=1 print(ans)
p02597
s621346720
Wrong Answer
N = int(input()) C=list(input()) X=0 Y=0 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 Y=ii break if i+Y==N-1: break print(X)
p02597
s087892779
Wrong Answer
N = int(input()) c = input() W = 0 R = c.count('R') ans = N t = 0 for i in range(N): if c[i] == 'W': W += 1 else: R -= 1 t = max(R,W) ans = min(ans, t) print(ans)
p02597
s053491450
Wrong Answer
def checkFunction(c): count = 0 while True: if not ('WR' in c): return count while c[0] == 'R': c = c[1:] while c[-1] == 'W': c = c[:-1] if c.index('R') + 1 != len(c): c = c.replace('WR', 'RR',1)[:-1] count += 1 return count + 1 N = int(input()) c= input() print(checkFunction(c))
p02597
s573001322
Wrong Answer
N = int(input()) c = input() W = 0 R = 0 for x in c: if x=='R': R += 1 ans = R for x in c: if c=='W': W += 1 else: R -= 1 ans = min(ans,max(R,W)) print(ans)
p02597
s082177813
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.rfind('WR') wnum = a[rightmostW:].count('R') print(wnum + 1) if __name__ == '__main__': main()
p02597
s454499317
Wrong Answer
N = int(input()) c= list(input()) if c.count('R') == N: print(0) exit() div=0 addcnt = 0 if N %2 == 1: div =1 Q = c[int(N/2)] # print(Q) if Q == 'R': addcnt +=1 # print('QQQ!') 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+addcnt)
p02597
s593561710
Wrong Answer
n = int(input()) c = list(input()) if n % 2 == 0: half = int(n / 2) odd =0 else: half = int((n-1) / 2) odd = 1 pre_w_num = 0 for i in range(half): if c[i] == "W": pre_w_num = pre_w_num + 1 post_r_num = 0 for j in range(half): if c[-1 *(j+1)] == "R": post_r_num = post_r_num +1 if pre_w_num <= post_r_num: ans = pre_w_num else: ans = post_r_num if odd == 1: print(c[half]) if c[half] == 'R': ans = ans +1 print(ans+1)
p02597
s758527394
Wrong Answer
N = int(input()) C=list(input()) X=0 for i in range(N): if C[i]=='W': for ii in range(N-1-i): if C[ii]=='R': C[i]='R' C[ii]='w' X=X+1 break print(X)
p02597
s613774182
Wrong Answer
import os import sys from atexit import register from io import BytesIO sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size)) sys.stdout = BytesIO() register(lambda: os.write(1, sys.stdout.getvalue())) input = lambda: sys.stdin.readline().rstrip('\r\n') raw_input = lambda: sys.stdin.readline().rstrip('\r\n') n = int(input()) seq = input() r = seq.count('R') ans = 0 cnt = 0 for i in xrange(n): if seq[i] == 'R': cnt += 1 else: ans += 1 cnt += 1 if cnt == r: break print(ans)
p02597
s451504265
Wrong Answer
n = int(input()) c = input() wcount = c.count('R') count = 0 for i in range(n): if c[i] == 'W' and i<= wcount: count += 1 print(count)
p02597
s540109423
Wrong Answer
n = int(input()) c = input() wcount = c.count('R') count = 0 for i in range(n): if c[i] == 'W' and i<= wcount: count += 1 print(count)
p02597
s024144384
Wrong Answer
N = int(input()) C = list(input()) W = 0 R = 0 for i in range(int(N/2)+1): if C[i] == 'W': W += 1 for i in range(int(N/2+1),N): if C[i] == 'R': R += 1 if W>R: print(R) else: print(W)
p02597
s696458576
Wrong Answer
import math #import sympy #n,d=map(int,input().split()) n=int(input()) c=input() rnum=c[0:int(len(c)/2)].count("W") wnum=c[int(len(c)/2):-1].count("R") lennum=int(len(c)/2) print(max(rnum,wnum))
p02597
s491081747
Wrong Answer
n = int(input()) s = input() cnt = 0 for i in range(n//2): if s[i]=='W': cnt+=1 print(cnt)
p02597
s695078632
Wrong Answer
from collections import deque n = int(input()) c = input() d = deque() a = 0; b = 0 for i in range(n): d.append(c[i]) for _ in range(len(d)): if d[0] == "R": d.popleft() else: break for _ in range(len(d)): if d[-1] == "W": d.pop() else: break for _ in range(len(d)//2): if d[-1] == "R": a += 1 d.pop() for _ in range(len(d)): if d[0] == "W": b += 1 d.popleft() print(min(a, b))
p02597
s300782188
Wrong Answer
N = int(input()) c = str(input()) rc = c.count('R') wc = c.count('W') if rc ==0 or wc ==0: print('0') else: s = c[:wc] wwc = wc-s.count('R') if wwc <= rc: print(wwc) else: print(rc)
p02597
s007750587
Wrong Answer
n = int(input()) c = input() c1 = 0 for v in c[: n // 2]: if v == "W": c1 += 1 c2 = 0 for v in c[n // 2 :]: if v == "R": c2 += 1 c3, c4 = 0, 0 for v in c: if v == "W": c3 += 1 else: c4 += 1 print(min(c1, c2, c3, c4))
p02597
s043845400
Wrong Answer
N = int(input()) C=list(input()) X=0 for i in range(N): if C[i]=='W': for ii in range(N-1-i): if C[ii]=='R': C[i]='R' C[ii]='w' X=X+1 break print(X)
p02597
s209519005
Wrong Answer
#dt = {} for i in x: dt[i] = dt.get(i,0)+1 import sys;input = sys.stdin.readline inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()] n = inp() s = input().strip() l,r = 0,n-1 ct = 0 if s.count('W') == 0: print(ct) exit() while l < r: while s[l] == 'R': if l >= r: break l += 1 while s[r] == 'W': if l >= r: break r -= 1 ct += 1 l += 1 r -= 1 print(ct)
p02597
s137623728
Wrong Answer
n = int(input()) if n%2==0 or n%5==0: print(-1) exit() ans,c = 0,0 while 1: c+=1 for i in range(10): if ((ans%10)+((n%10)*i)%10)%10==1: ans += n*i #print(ans,i) break ans = ans//10 if ans==0: break print(c)
p02597
s376158883
Wrong Answer
import sys input = sys.stdin.readline n = int(input()) s = list(input()) ans = 0 for i in range(n - 1): idx = n - 1 - i if s[idx] == 'W' and s[idx + 1] == 'R': ans += 1 s[idx] = 'R' print(ans)
p02597
s555931816
Wrong Answer
N = int(input()) C = input() C = C[:len(C)//2] print(C.count("W"))
p02597
s249935389
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
s109982633
Wrong Answer
N = int(input()) c = list(input()) ans = 0 cnt = c.count("W") ans = c[N-4:].count("R") if cnt != 0: print(ans) else: print(0)
p02597
s578690748
Wrong Answer
N = int(input()) A = input() a = A.count('W') b = A.count('R') c = 'R'*a+'W'*b n = 0 m = 0 for i in range(N): if A[i] != c[i]: if A[i] == 'W': n+=1 if A[i] == 'R': m+=1 e = min(n,m)+abs(n-m) print(min(a,b,e))
p02597
s110010041
Wrong Answer
n = int(input()) m = input() runlength = [] count = 1 for i in range(len(m)): if i == n-1: runlength.append([m[i],count]) break if m[i] == m[i+1]: count += 1 elif m[i] != m[i+1]: runlength.append([m[i],count]) count = 1 count = 0 for i,j in runlength: if i == "W": count += j count -= 1 print(count)
p02597
s757852374
Wrong Answer
# -*- coding: utf-8 -*- N = int(input()) c = input() #t = c.count("R") print(c.count("R")-c[:2].count("R"))
p02597
s121320910
Wrong Answer
N=int(input()) S=input() ans=0 i=0 j=N-1 while i<=j: while i<N: if S[i]=='W': break else: i+=1 while j>0: if S[j]=='R': break else: j-=1 if i<=j: ans+=1 i+=1 j-=1 print(ans)
p02597
s970238376
Wrong Answer
import sys input=sys.stdin.readline n=int(input()) c=input().rstrip() l=0 r=n-1 ans=0 while True: while c[l]=='R': l+=1 if l==n: break while c[r]=='W': r-=1 if r==-1: break if l>r: break ans+=1 l+=1 r-=1 temp=0 for i in c: if i=='R': temp+=1 temp=min(temp,n-temp) ans=min(ans,temp)
p02597
s247466605
Wrong Answer
k = int(input()) s = input() res = 0 j = k - 1 for i in range(k//2): if s[i] == 'W' and s[j] == 'R': res += 1 j -= 1 elif s[i] == 'W' and s[j] == 'W': res += 1 j -= 1 if k % 2 and s[k//2]:res += 1 print(res)
p02597
s142204563
Wrong Answer
input() s = input() pref = 0 total = s.count('R') res = int(1e9) for i in range(total): pref += s[i] == 'R' res = min(res, total - pref) print(res)
p02597
s036983682
Wrong Answer
n=int(input()) c=list(input()) count=0 for i in range(n): if c[i]=='W': for j in range(n-1,i+1,-1): if c[j]=='R': c[j]='W' count+=1 print(count)
p02597
s957091546
Wrong Answer
N=int(input()) S= list(input()) W_count=S.count('W') R_count=S.count('R') if((W_count==0) or (R_count==0)): print(0) else: if(W_count==R_count): print(R_count-S[:len(S)//2].count('R')) else: if(len(S)%2==0): print(S[:len(S)//2].count('R')-S[:len(S)//2].count('W')) else: print(S[:len(S)//2+1].count('R')-S[:len(S)//2+1].count('W'))
p02597
s204041303
Wrong Answer
n = int(input()) C = input() t = sum(c == 'R' for c in C) print(sum(c == 'R' for c in C[:t]))
p02597
s770964327
Wrong Answer
N = int(input()) s = input() times = len(s) R, L = 0, s.count("R") for c in s: if c == "W": R += 1 else: L -= 1 if times > max(R, L): times = max(R, L) print(times)
p02597
s833105442
Wrong Answer
n=int(input()) c=list(input()) rall=c.count('R') wlef=c[:rall+1].count('W') print(wlef)
p02597
s914993141
Wrong Answer
n = int(input()) c = input() wi = c.find('W') ri = c.rfind('R') if wi == -1 or ri == -1: print(0) else: ans = 0 while wi < ri: wi = c[wi:].find('W') + wi + 1 ri = c[:ri].rfind('R') ans += 1 print(ans)
p02597
s996540911
Wrong Answer
N = int(input()) C=list(input()) X=0 Y=0 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 Y=ii break if i+Y==N-2: break print(X)
p02597
s959548878
Wrong Answer
N = int(input()) c = list(input()) print(c) red=0 for i in c: if i=="R": red+=1 count = 0 for i in range(red): if c[i]=="W": count+=1 print(count)
p02597
s592486390
Wrong Answer
n = int(input()) str_list = list(input()) flag = 0 if (str_list[0] == 'W' and str_list[1] == 'R') and str_list[n-1] == 'R': str_list[0] = 'R' str_list[n-1] = 'W' flag += 1 elif (str_list[0] == 'W' and str_list[1] == 'W') and str_list[n-1] == 'R': str_list[0] = 'R' str_list[n-1] = 'W' flag += 1 for i in range(n-1): if str_list[i] == 'W' and str_list[i+1] == 'R': str_list[i+1] = 'W' flag += 1 print(flag)
p02597
s200759239
Wrong Answer
n=int(input()) s=input() print(s[:n//2].count('W'))
p02597
s339407759
Wrong Answer
N = int(input()) S = input() r = S.count('R') w = S.count('W') if r == N or r == 0: print(0) exit() a = S[:r+1].count('W') print(a)
p02597
s618858585
Wrong Answer
n = int(input()) S = list(input().split()) str_list = [] for s in S: str_list.append(list(s)) count = 0 for i in range(1, n+1): if str_list[0][-i] == 'R': count += 1 else: break if n % 2 == 0: b = n // 2 else: b = (n + 1) // 2 c = str_list[0][:b].count('W') print(max(count, c))
p02597
s443235388
Wrong Answer
N=int(input()) C=input() C=[str(c) for c in C] for i in range(N): if C[i]=="R": C=C[i:] break for i in range(N): if C[-i]=="R": C=C[:-i] break print(min(C.count("R"),C.count("W")))
p02597
s920021978
Wrong Answer
from copy import deepcopy N = int(input()) c = list(input()) n = 0 OK = False while not OK: ni = 0 OK = True for i in range(N - 1): if c[i] == 'W' and c[i + 1] == 'R': c[i] = 'R' ni += 1 OK = False ni = (ni + 1) // 2 n += ni print(n)
p02597
s866398291
Wrong Answer
n = int(input()) c = input() if len(c) == c.count('W') or len(c) == c.count('R'): print(0) harf = round(len(c)/2) wCnt = c[:harf].count('W') rCnt = c[-harf:].count('R') print(wCnt if wCnt >= rCnt else rCnt)
p02597
s745292421
Wrong Answer
a=int(input()) b=input() c=int(a/2) d=0 e=a-1 i=0 while i+1<e: if b[i]=='W': for j in range(i,e+1)[::-1]: if b[j]=='R': d=d+1 e=j-1 break i=i+1 print(d)
p02597
s859280079
Wrong Answer
def solve(): N = int(input()) C = input() left = 0 right = len(C) -1 while left < right and C[left] == 'R': left += 1 while left < right and C[right] == 'W': right -= 1 ans = 0 while left < right: while left < right and C[left] == 'R': left += 1 while left < right and C[right] == 'W': right -= 1 ans += 1 left += 1 right -= 1 print(ans) if __name__ == "__main__": solve()
p02597
s832071139
Wrong Answer
N = int(input()) C = input() if N % 2 == 0: mid = N//2 else: mid = N//2+1 Wcount = C.count("W", 0, mid) if N%2!=0 and C[mid-1] == "W": Wcount -= 1 print(Wcount)
p02597
s621876919
Wrong Answer
#!/usr/bin/env python3 # from numba import njit # input = stdin.readline # @njit def solve(n,s): flag = False whiteCount = 0 for i in range(n-1,-1,-1): if s[i] == "R": flag = True if s[i] == "W" and flag: whiteCount += 1 res = 0 for i in range(n): if s[n-i-1] == "W" and i+1 > whiteCount: res += 1 return res def main(): N = int(input()) s = input() print(solve(N,s)) return if __name__ == '__main__': main()
p02597
s631005688
Wrong Answer
input() num = input() print(num.find('WR'))
p02597
s522879485
Wrong Answer
n = input() wr = input() j = len(wr) ans = 0 for i in range(0,len(wr)): if wr[i] == 'W': while j>=1: j-=1 if wr[j] == 'R': ans+=1 break print(ans)
p02597
s790472381
Wrong Answer
N=int(input()) C=list(input()) ans=0 w=0 r=0 for i in range(N//2): print(i,C[i]) if C[i]=='W': w+=1 if C[i-2]=='R': r+=1 if w==0 or r==0: ans=0 else: ans=max(w,r) print(ans)
p02597
s811420577
Wrong Answer
N = int(input()) C = input() if N % 2 == 0: mid = N//2 else: mid = N//2+1 Wcount = C.count("W", 0, mid) if C[mid-1] == "W": Wcount -= 1 print(Wcount)
p02597
s395979770
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: print(b-1) else: print(b)
p02597
s569734898
Wrong Answer
N = int(input()) #stones = list(input()) stones = input() print(stones) a = stones.count('W') b = stones.count('R') left_side =stones.count('W', 0, a) print(left_side)
p02597
s075057429
Wrong Answer
# !/usr/bin/python3 def solve(a, n): count = 0 end = n-1 for i in range(n): if a[i] == 'W': for j in range(end, i-1, -1): if i == j: return count if a[j] == 'R': count += 1 end -= 1 break return count if __name__ == "__main__": n = int(input()) a = input() print(solve(a, n))
p02597
s934085016
Wrong Answer
n = int(input()) c = list(input()) ans = 0 if c.count('W') == n or c.count('W') == 0: ans =0 else: if n % 2 == 0: a = n //2 c_for = c[:a] c_back = c[a:] ans = max(c_for.count('W'),c_back.count('R')) else: a = n//2 a = n //2 c_for = c[:a] c_back = c[a+1:] ans = max(c_for.count('W'),c_back.count('R')) print(ans)
p02597
s183018930
Wrong Answer
N = int(input()) c = input() ans = 0 fs = 0 ls = N - 1 for _ in range(N): for i in c[fs:ls]: if i == 'W': break fs += 1 for i in c[fs:ls:-1]: if i == 'R': break ls -= 1 if fs >= ls: break ans += 1 fs += 1 ls -= 1 #print(c[fs:ls] + 1) if (ls - fs) <= 1: break print(ans)
p02597
s875559673
Wrong Answer
import sys readline = sys.stdin.readline from collections import deque def solve(): N = int(readline()) C = readline().rstrip() R, W = 'R', 'W' reds = deque(i for i in range(len(C)) if C[i] == 'R') whites = deque(i for i in range(len(C)) if C[i] == 'W') count = 0 print(reds, whites) while len(whites) > 0 and len(reds) > 0 and whites[0] < reds[-1]: reds.pop() whites.popleft() count += 1 print(count) solve()
p02597
s990552184
Wrong Answer
from collections import Counter N = int(input()) c = input() counter = Counter(c) if counter["R"] == 0 or counter["W"] == 0: print(0) else: first_r = 0 for i in range(N): if c[i] == "R": first_r = i+1 break if first_r <= counter["R"]: print(counter["R"]-1) else: print(counter["R"])
p02597
s511722544
Wrong Answer
from itertools import accumulate N = int(input()) S = list(input()) W = [0]*N R = [0]*N ans = N for i in range(N): if S[i] == "W": W[i] = 1 else: R[i] = 1 R.reverse() R = list(accumulate(R)) W = list(accumulate(W)) if R[0] == 0 or W[N-1] == 0: ans = 0 else: sakai = R[N-1] ans = max(W[sakai-1], R[sakai]) print(ans)
p02597
s029921368
Wrong Answer
import re N = int(input()) C = input() wLen = len(C.replace('R', '')) rLen = len(C.replace('W', '')) if wLen == 0 or rLen == 0: print(0) else: tmp = C tmpRes = min(wLen, rLen) for i in range(tmpRes): tmp = re.sub('^R*', '', tmp) tmp = re.sub('W*$', '', tmp) tmpLen = len(tmp) - max(len(re.sub('^W*', '', tmp)), len(re.sub('R*$', '', tmp))) tmp = tmp[int(tmpLen): int(len(tmp) - tmpLen)] if len(tmp) == 0: tmpRes = i + 1 break print(tmpRes)
p02597
s150972244
Wrong Answer
N = int(input()) C = list(input()) lW = 0 rW = 0 for i in range(0,int(N/2)): if C[i] == 'W': lW += 1 for i in range(int(N/2),N): if C[i] == 'W': rW += 1 if lW>=rW: print(lW) else: print(rW-lW)
p02597
s804368932
Wrong Answer
n=int(input()) c=input() rcnt=[0]*(n+1) wcnt=[0]*(n+1) for i in range(n): if c[i]=="W": wcnt[i+1]=wcnt[i]+1 rcnt[i+1]=rcnt[i] else: rcnt[i+1]=rcnt[i]+1 wcnt[i+1]=wcnt[i] ans=n+100 for i in range(n): cw=wcnt[i+1] cr=rcnt[-1]-rcnt[i+1] ans=min(ans,cw+cr-min(cr,cw)) ans=min(ans,wcnt[-1]) print(ans)
p02597
s214305408
Wrong Answer
import collections n=int(input()) cnt=0 lst=list(str(input())) y=collections.Counter(lst[:(n//2)]) Ry=y["R"] Wy=y["W"] z=collections.Counter(lst[(n//2):]) Rz=z["R"] Wz=z["W"] if Rz>Ry: cnt+=min(Rz, Wy) else: cnt+=min(Ry, Wz) print(cnt)
p02597
s818016322
Wrong Answer
N = int(input()) ans = 0 i = 0 c = input() # leftRed = str.count("R", 0,N/2-1) leftWhite = c.count("W", 0,int(N/2)) rightRed = c.count("R", int(N/2),N) # rightWhite = str.count("W", N/2,N-1) ans += min(leftWhite, rightRed) if leftWhite > rightRed: ans += (leftWhite - rightRed) print(ans)
p02597
s586135251
Wrong Answer
n = int(input()) c = list(input()) c = c[::-1] cou = 0 for i in range(len(c)//2): if c[i] == "R": cou += 1 print(cou)
p02597
s546920441
Wrong Answer
n = int(input()) c_array = list(input()) w_num = c_array.count('W') r_num = n-w_num def get_ans(half): wl_num = c_array[:half].count('W') rr_num = c_array[half:].count('R') if w_num == 0 or r_num == 0: ans = 0 else: ans = min(wl_num, rr_num) + abs(wl_num-rr_num) return ans ans = min(get_ans(w_num), w_num, r_num) print(ans)
p02597
s489900012
Wrong Answer
n = int(input()) s = input() red = [] white = [] for i in range(n): if s[i] == 'W': white.append(i) for i in range(n - 1, -1, -1): if s[i] == 'R': red.append(i) print(white, red) if min(len(red), len(white)) == 0: print(0) exit() for i in range(min(len(red), len(white))): if white[i] >= red[i]: print(i) exit()
p02597
s782878931
Wrong Answer
n = int(input()) c = input() wi = c.find('W') ri = c.rfind('R') + 1 if wi == -1 or ri == -1: print(0) else: ans = 0 while wi < ri: wi = c[wi:].find('W') + wi + 1 ri = c[:ri].rfind('R') ans += 1 print(ans)
p02597
s202315415
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] == 'W' and l < r: r -= 1 ans += 1 l += 1 r -= 1 if l >= r: break # print(l, r) print(ans)
p02597
s112996317
Wrong Answer
n = int(input()) s = input() ans = 0 for i in s[0:n//2]: if i == "W": ans += 1 if n % 2 != 0: if s[0:n//2+1] == "R": ans += 1 print(ans)
p02597
s235914014
Wrong Answer
N = int(input()) S = input() n=0 while S.find("W")<S.rfind("R"): S = S[S.find("W")+1:S.rfind("R")] n+=1 print(n)
p02597
s475290201
Wrong Answer
N = int(input()) mozi = input() mozi2 = list(mozi) a = len(mozi2) num_w = mozi2.count("W"); num_r = mozi2.count("R") list_w2 = mozi2[(a-num_w):]; list_w1 = mozi2[:(a-num_w)] list_r2 = mozi2[(a-num_r):]; list_r1 = mozi2[:(a-num_r)] if num_w <= num_r: if "W" in list_w2: print(list_w1.count("W")) else: print(num_w) else: if "R" in list_r1: print(list_r2.count("R")) else: print(num_r)
p02597
s987525790
Wrong Answer
n=int(input()) s = input() ans = 0 for i in s: if i=="R": ans+=1 for i in range(0,ans): if i=="R": ans-=1 print(ans)
p02597
s452113574
Wrong Answer
from collections import Counter N = int(input()) c = input() counter = Counter(c) if counter["R"] == 0 or counter["W"] == 0: print(0) else: first_r = 0 for i in range(N): if c[i] == "R": first_r = i+1 break if first_r <= counter["R"]: print(min(counter["R"]-1,counter["W"])) else: print(min(counter["R"], counter["W"]))
p02597
s862314188
Wrong Answer
N = int(input()) a = list(input()) if N%2==0: x = a[0:int(N/2)] y = a[int(N/2):N] else: x = a[0:int(N/2)] y = a[int(N/2)+1:N] count_ri = x.count('W') count_le = y.count('R') if a.count('W') ==0 or a.count('R')==0: print(0) elif x.count('W')==0 and y.count('R')==0: print(0) elif count_ri==count_le: print(count_ri) elif count_ri>count_le: print(count_le) elif count_ri<count_le: print(count_ri)
p02597
s960810629
Wrong Answer
import math N = int(input()) S = str(input()) print(S[:math.floor(N/2)].count('W'))
p02597
s443528547
Wrong Answer
N = int(input()) c = list(input()) left_white = 0 Rcount = c.count("R") for i in range(0,len(c)): if c[i] == "R": left_white = i break #print(i,''.join(c[i:])) if left_white >= Rcount: print(c.count("R")) elif i == 0: print(0) else: print(c[i+1:].count("R"))
p02597
s117848699
Wrong Answer
n = int(input()) c = input() def try_count(c, color): try: if c.count(color)!=0: return c.count(color) else: return n except: return 0 all_r = try_count(c, 'R') all_w = try_count(c, 'W') left_w = try_count(c[:all_w], 'W') # print(all_r,all_w,left_w) print(min(all_r,all_w,left_w))
p02597
s240726748
Wrong Answer
n = int(input()) arr = list(input()) arr = [1 if i == "R" else 0 for i in arr] rarr = list(reversed(arr)) a = sum(arr) if a == 0 or a == n: ans = 0 else: widx = arr.index(0) ridx = n - rarr.index(1) arr = arr[widx:ridx] rsum = sum(arr) ws = arr[:-rsum].count(0) rs = arr[-rsum:].count(1) ans = max(ws,rs) print(ans)
p02597
s373283821
Wrong Answer
import sys input = sys.stdin.readline def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) n = I() mychr = input().rstrip() result = float('inf') red = 0 for i in mychr: if i == "R": red += 1 R = 0 W = 0 for index, i in enumerate(mychr): if i == "R": R+=1 else: W+=1 temp = max(W,red-R) result = min(result, temp) print(result)
p02597
s385474072
Wrong Answer
n = int(input()) s = input() ans = 0 i = 0 while True: r = 0 w = 0 if s[i] == 'W': w += 1 else: r += 1 i += 1 while i < n and not (s[i] == 'W' and s[i - 1] == 'R'): if s[i] == 'W': w += 1 else: r += 1 i += 1 ans += min(r, w) if i == n: break print(ans)
p02597
s097322454
Wrong Answer
N = int(input()) C = input() w = sum([True for c in C if c == "W"]) r = N - w count = 0 for i, c in enumerate(C): if i < w and c == 'W': count += 1 print(count)
p02597
s765845930
Wrong Answer
n = int(input()) c = input() wcount = c.count('R') count = 0 for i in range(n): if c[i] == 'W' and i >= wcount: count += 1 print(count)