problem_id
stringclasses
100 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
6
806
p02597
s312324233
Wrong Answer
n = int(input()) c = input() lists = list(c) cnt = 0 while 1: if lists[cnt] == "W": cnt += 1 if cnt == len(lists): break else: break number = 0 for i in range(len(lists) - cnt): if lists[i + cnt] == "W": number += 1 print(number)
p02597
s671671203
Wrong Answer
n = int(input()) c = input() count = 0 for i in range(n//2): if 'W' == c[i]: count += 1 print(count)
p02597
s993225114
Wrong Answer
n = int(input()) c = list(input()) w = c.count('W') w2 = c[:w].count('W') r2 = c[w:].count('R') print(min(w2,r2))
p02597
s957825249
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
s395501911
Wrong Answer
from collections import Counter import copy n=int(input()) c=input() cl=copy.deepcopy(c) cl=list(cl) d=Counter(c) ans=0 if d["R"]==0 or d["W"]==0: print(0) exit() swap=0 for i in range(n): indexes = [j for j, x in enumerate(cl) if x == "R"] if cl[i]=="W": cl[indexes[-1]]="W" cl[i]="R" swap+=1 else: break if swap>=n//2: break d=Counter(cl[cl.index("W"):]) ans+=swap+d["R"] print(ans)
p02597
s503015908
Wrong Answer
N = int(input()) A = list(input()) a = 0 B = [] for i in range(N): if A[i] == 'W': a += 1 B.append(a) if a >= N - a: ans = B[N - a] else: ans = B[a] print(ans)
p02597
s925546424
Wrong Answer
N = int(input()) C = input() A = [] for c in C: if c=='W': A.append(0) else: A.append(1) l = 0 r = N - 1 ans = 0 while l < r: if not A[l] and A[r]: ans+=1 l +=1 r-=1 elif not C[l]: r-=1 elif C[r]: l+=1 print(ans)
p02597
s471677475
Wrong Answer
n = int(input()) s = list(input()) ans = 0 right = n-1 for i in range(n//2+1): if s[i] == "W": while right >= i: if s[right] == "R": s[right] = "W" s[i] = "R" ans += 1 right -= 1 break else: right -= 1 print(ans)
p02597
s988539319
Wrong Answer
N = int(input().strip()) C = [c for c in input().strip()] if "W" not in C or "R" not in C: print(0) import sys; sys.exit(0) cnt = 0 i = 0 j = len(C) - 1 while i < j: while C[i] != "W": i += 1 while C[j] != "R": j -= 1 cnt += 1 C[i] = "R" C[j] = "W" i += 1 j -= 1 print(cnt)
p02597
s204224949
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)
p02597
s188829831
Wrong Answer
n = int(input()) stones = list(input()) w_num = 0 r_num = 0 for i in stones: if i == 'W': w_num += 1 else: r_num += 1 goal = 'R' * w_num + 'W' * r_num index = 0 poplist = list() for i in stones: if i == goal[index]: poplist.append(index) index += 1 for i in sorted(poplist, reverse=True): stones.pop(i) w_num = 0 r_num = 0 for i in stones: if i == 'W': w_num += 1 else: r_num += 1 print(min(w_num, r_num))
p02597
s934944790
Wrong Answer
n = int(input()) c = list(input()) if n % 2 == 0: half = int(n / 2) else: half = int((n-1) / 2) 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 print(ans)
p02597
s572370818
Wrong Answer
n = int(input()) c = input() wc = c.count('W') rc = c.count('R') print(min(c[:rc].count('W'), c[wc-1:].count('R'), n - rc, n-wc))
p02597
s600180565
Wrong Answer
N = int(input()) S = input() A = int(S.count("R")) if A == N: print(A) exit() s = S[:A] B = int(s.count("R")) print(A-B)
p02597
s533806593
Wrong Answer
n = int(input()) s = list(input()) if len(set(s)) == 1: print(0) elif n % 2 == 0: r = s[:n//2].count('W') w = s[n//2:].count('R') print(max(r, w)) else: r = s[:n//2].count('W') w = s[n//2+1:].count('R') print(max(r, w))
p02597
s244227368
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(w) else: print(r)
p02597
s806189407
Wrong Answer
N = int(input()) c = input() if (("R" not in c) or ("W" not in c)): print(0) exit(0) i = 0 j = N - 1 count = 0 while (True): while (c[i] != "W"): i = i + 1 while (c[j] != "R"): j = j - 1 count += 1 i = i + 1 j = j - 1 if (i > j or i == j or i >= N or j < 0): break print(count)
p02597
s334215678
Wrong Answer
N = int(input()) C = input() if "WR" not in C: print(0) elif C[:2]=="WR": print(C.count("R")-1) else: print(C.count("R"))
p02597
s923781050
Wrong Answer
N = int(input()) C = input() left = N - 1 count = 0 for right in range(N): if right == left: break if C[right] == 'W': while C[left] == 'W' and right <= left: left -= 1 if C[left] == 'W': break count += 1 left -= 1 print(count)
p02597
s753378617
Wrong Answer
N = int(input()) C = input() r_cnt = 0 for c in C: if c == 'R': r_cnt += 1 ans = N r2w = r_cnt w2r = 0 for c in C: if c == 'W': w2r += 1 elif c == 'R': r2w -= 1 ans = min(ans, max(r2w, w2r)) print(ans)
p02597
s533523049
Wrong Answer
n = int(input()) c = input() s1 = [0] for i in range(n): if c[i] == 'W': s1.append(s1[-1] + 1) else: s1.append(s1[-1]) s2 = [0] for i in range(n): if c[i] == 'R': s2.append(s2[-1] + 1) else: s2.append(s2[-1]) s2.reverse() ans = 1001001001 for i in range(n+1): ans = min(ans, s1[i] + s2[i]) print(ans)
p02597
s784368498
Wrong Answer
N = int(input()) RW = input() j = N-1 count = 0 for i in range(N): if RW[i]=='W': while i<j: if RW[j]=='R': count += 1 break j -= 1 print(count)
p02597
s931560511
Wrong Answer
n = int(input()) k = list(input()) ws = 0 rs = 0 moves = 0 for i in range(0, n-1): if k[i] == "W": ws += 1 else : rs += 1 if ws == 0 or rs == 0: print(0) if rs < ws: for i in range(0, rs-1): if k[i] == "W": moves += 1 else: for i in range(n-1, ws): if k[i] == "R": moves += 1 print(moves)
p02597
s742289059
Wrong Answer
n = int(input()) c = list(input()) c = c[::-1] cou = 0 for i in range(len(c)//2): if c[i] == "R": for j in range(len(c)-1, i, -1): if c[j] =="W": c[i], c[j] = c[j], c[i] cou += 1 break print(cou)
p02597
s308509136
Wrong Answer
N = int(input()) c = input() tmp = 0 ans = 0 count = 0 if(N % 2 == 0): tmp = N - (N//2) + 1 else: tmp = N - (N//2) for i in range(N): if(c[i] == "W"): count += 1 if(count == N): print("0") exit() for i in range(tmp): if(c[i] == "W"): ans += 1 print(str(ans))
p02597
s335197035
Wrong Answer
n = int(input()) c = input() ans = 0 l = 0 r = n-1 lsl = 0 lsr = 0 while l < n: lc = c[l] if lc == 'W': while 0 <= r: rc = c[r] if rc == 'R' and l < r: ans += 1 lsl = l lsr = r r -= 1 break r -= 1 l += 1 #print('mid : ', ans, lsl, lsr) if (lsr - lsl) > 1: for i in range(lsl+1, lsr): if c[i] == 'W': ans += 1 print(ans)
p02597
s591225953
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 = sum(c) w=0 r=0 for i in range(n): if c[i] == 0 and i <= b: r+=1 if c[i] == 1 and i > b: w+=1 print(max(w,r))
p02597
s842484875
Wrong Answer
n=int(input()) c=list(input()) ans=0 for i in range(n//2): if c[i]=="W" and c[-i-1]=="R": ans+=1 elif c[i]==c[-i+1]=="R": continue else: ans+=c[i:-i-1].count("R") break print(ans)
p02597
s192474005
Wrong Answer
n = int( input() ) c = list( input() ) l = 0 r = n - 1 ans = 0 while l < r: while c[ l ] == "R" and l < n - 1: l += 1 while c[ r ] == "W" and r > 1: r -= 1 if l < r: c[ l ] = "R" c[ r ] = "W" ans += 1 print( ans )
p02597
s003565084
Wrong Answer
# -*- coding: utf-8 -*- import math n = int(input()) color = list(input()) i = 0 j = n-1 count = 0 while(i<j): found1 = 0 found2 = 0 for k in range(n-1-i): if color[i+k] == 'W': i = i+k+1 found1 = 1 break for k in range(j): if color[j-k] == 'R': j = j-k-1 found2 = 1 break if found1*found2 == 0: break else: count += 1 print(count)
p02597
s626528491
Wrong Answer
N=int(input()) white=0 red=0 W=list(str(input())) 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==0 or red==0: print("0") exit() Z=min(white,red) rest=abs(white-red) Z=Z+rest if (N/2)%1!=0: if W[N//2+1]=="W": Z+=1 print(Z)
p02597
s419779260
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
s384795448
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, rl-(wl-l)]))
p02597
s958539959
Wrong Answer
N = int(input()) A = list(input()) a = 0 B = [] for i in range(N): if A[i] == 'W': a += 1 B.append(a) ans = B[N - a - 1] print(ans)
p02597
s291052371
Wrong Answer
N = int(input()) c = input() d = list(c) i = 0 j = N - 1 result = 0 while i != j and i < j: if d[i] == 'W': while d[j] != 'R' and i < j: j -= 1 d[i] = 'R' d[j] = 'W' result += 1 i += 1 print(result)
p02597
s420828051
Wrong Answer
n = int(input()) c = list(input()) w = c.count('W') w2 = c[:w].count('W') print(w2)
p02597
s362864033
Wrong Answer
n = int(input()) s = input() w = s.count('W') an1 = s[-w:].count('R') an2 = s[:w].count('R') print(min(an1, an2))
p02597
s389891764
Wrong Answer
n = int(input()) moji = input() c = [] for i in range(len(moji)): c.append(moji[i]) j = len(c)-1 count = 0 for i in range(len(c)//2): if c[i] == "W": # and c[i+1] == "R": while j >= 0: if c[j] == "R": c[i] = "R" c[j] = "W" count += 1 break j -= 1 # print(c) print(count)
p02597
s565628722
Wrong Answer
n = int(input()) c = input() le = len(c) if le % 2 == 0: i = le // 2 else: i = le // 2 + 1 ans = c[:i].count("W") print(ans)
p02597
s282389669
Wrong Answer
N = int(input()) C = input() wr = 0 wflag = 0 wsum = 0 wtemp = 0 for c in C: if c == "W": wtemp += 1 wflag = 1 elif wflag: wr += 1 wsum += wtemp wtemp = 0 wflag = 0 print(wsum-wr//2)
p02597
s406154115
Wrong Answer
n = int(input()) s = input() c = 0 tmp = 0 r = 0 for i in range(n-1): if s[i] == "W": tmp += 1 if s[i+1] == "R": c += tmp r += 1 tmp = 0 print(c - r//2)
p02597
s171098598
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 li[i] = "R" li[j] = "W" ans += 1 print(ans) if __name__ == '__main__': main()
p02597
s984050698
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
s152466210
Wrong Answer
N = int(input()) S = input() prev = S[0] cur = 'R' count = 0 wNum = 0 changedPoint = 0 for i in range(N-1, -1, -1): cur = S[i] if cur == 'R': for j in range(wNum, N - i): if S[j] == 'W': wNum = j + 1 changedPoint = j break if wNum != 0: count += 1 prev = cur if changedPoint >= i: break print(count)
p02597
s463482155
Wrong Answer
n = int(input()) C = input() A = [0]*(n+1) cnt = 0 for i, c in enumerate(C): if c == "R": cnt += 1 A[i+1] = 1 A[i+1] += A[i] ans = float("inf") for i in range(1, n+1): W_l = i - A[i] R_r = cnt - A[i] temp = min(W_l, R_r) + abs(W_l-R_r) ans = min(ans, temp) print(ans)
p02597
s496875213
Wrong Answer
N = int(input()) A = list(input()) a = 0 B = [] for i in range(N): if A[i] == 'W': a += 1 B.append(a) if a >= N - a: ans = B[N - a - 1] else: ans = B[N - a - 1] - a print(ans)
p02597
s804043233
Wrong Answer
n = int(input()) c = input() wc = c.count('W') rc = c.count('R') print(min(c[:rc].count('W'), c[wc:].count('R'), n - wc, n - rc))
p02597
s454058623
Wrong Answer
import sys N = int(input()) C = list(input()) count = 0 i = 0 j = len(C) - 1 if not 'R' in C or not 'W' in C: print(0) sys.exit() while i + 1 <= j - 1: while C[i] == 'R': i += 1 while C[j] == 'W': j -= 1 C[i], C[j] = C[j], C[i] count += 1 print(count)
p02597
s419917058
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 s = s[L + 1:r] cnt += 1 if L != -1: cnt += L + 1 print(cnt)
p02597
s031754204
Wrong Answer
import math n = int(input()) # c = list(input().split()) c = input() whiteCount = 0 for i in range(math.ceil(n/2)): if c[i] == "W": whiteCount += 1 print(whiteCount)
p02597
s498647946
Wrong Answer
import collections as c n = int(input()) s = list(input()) cnt = 0 while c.Counter(s[:cnt+1])["W"]<c.Counter(s[cnt:])["R"]: cnt += 1 print(cnt)
p02597
s907730111
Wrong Answer
import sys input = sys.stdin.readline n = int(input()) s = input() ans = 0 for i in range(n - 1): if s[i] == 'W' and s[i + 1] == 'R': ans += 1 print(ans)
p02597
s485268035
Wrong Answer
N = int(input()) tmpN = N C = input() if N % 2 == 1: N += 1 N = int(N / 2) result = C.count('R',N) if C.count('R') == tmpN: print('0') else: print(result)
p02597
s473409139
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
s208371966
Wrong Answer
import collections n = int(input()) c = list(input()) C = collections.Counter(c) C_2 = collections.Counter(c[:n//2]) tmp_1 = min(C['W'],C['R']) tmp_2 = min(C_2['W'],C['R']-C_2['R']) ans = min(tmp_1,tmp_2) print(ans)
p02597
s882126404
Wrong Answer
N = int(input()) C = list(input()) W = 0 R = 0 for i in range(0,int(N/2)): if C[i] == 'W': W += 1 for i in range(int(N/2),N): if C[i] == 'R': R += 1 if W>=R: print(R) else: print(W)
p02597
s431453096
Wrong Answer
import math n=int(input()) k=list(input()) if len(set(k))==1: print("0") print(round(math.log2(n)))
p02597
s254678438
Wrong Answer
N = int(input()) C = list(map(str, input())) W = N - C.count('W') R = N - C.count('R') CH = R - C[:R].count('R') print(min(W,R, CH))
p02597
s505789893
Wrong Answer
N = int(input()) C = input() if C[0]=="W": w = C.find("R") r = C[w:].find("W") t = C.count("R") if w<=t-r: print(t-w) else: print(t) else: r1 = C.find("W") w = C[r1:].find("R") r2 = C[r1+w:].find("W") t = C.count("R") if w<=t-r1-r2: print(t-r1-r2) else: print(t)
p02597
s230952118
Wrong Answer
N = int(input()) C = input() a = N // 2 if N & 2 == 0: right_W = C[:a].count ('W') else: right_W = C[:a+1].count('W') left_R = C[a:].count ('R') ans = min(right_W, left_R) print(ans)
p02597
s991963593
Wrong Answer
N=int(input()) S=input() firstR=S.find('R') Sother=S[firstR+1:] otherR=Sother.count('R') print(firstR+otherR-1)
p02597
s199874518
Wrong Answer
n = int(input()) s = list(input()) count_red = s.count('R') count_white = 0 A = [] for i in range(n): if s[i] == 'R': count_red -= 1 if s[i] == 'W': count_white += 1 A.append(max(count_red, count_white)) print(min(A))
p02597
s053544705
Wrong Answer
N = int(input().strip()) S = input().strip() if S.count('W') == 0 or S.count('R') == 0: print(0) else: count = 0 SS = S[:len(S)//2] A = sorted(S)[:len(S)//2] for ss,a in zip(SS,A): if ss != a: count+=1 print(count)
p02597
s294016825
Wrong Answer
N = int(input()) C = input() a = N // 2 right_W = C[:a].count ('W') left_R = C[a:].count ('R') ans = min(right_W, left_R) print(ans)
p02597
s208120255
Wrong Answer
a = int(input()) b = input() b.count('R') c = b.find('R') d =b[c+1:].count('R') if b.count('W') == 0: print(0) elif b.find('R') < b.find('W'): print(0) elif (a - b.find('R'))==b.count('R') and b.count('R') == b.count('W'): print(b.find('R')) else: print(c + (d-c))
p02597
s558343967
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
s931207238
Wrong Answer
n = input() wr = input() j = len(wr)-1 ans = 0 for i in range(0,len(wr)): if wr[i] == 'W': while j>=1: if wr[j] == 'R': ans+=1 break j-=1 print(ans)
p02597
s857812282
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 i in range((len(d)+1)//2): if d[-i-1] == "R": a += 1 for i in range((len(d)+1)//2): if d[i] == "W": b += 1 print(min(a, b))
p02597
s562313579
Wrong Answer
X = input() count_w, n, count = X.count('W'), len(X), 0 for i in range(n - 1, n -1 - count_w, -1): count += 1 if X[i] == 'R' else 0 print(count)
p02597
s415614099
Wrong Answer
import sys def input(): return sys.stdin.readline().rstrip() def main(): n = int(input()) C = input() sum_r, sum_w = 0, 0 for c in C: if c == 'R': sum_r += 1 ans = 10000000 for i in range(n-1): if C[i] == 'W': sum_w += 1 else: sum_r -= 1 if C[i:i+2] == "WR": ans = min(ans, max(sum_w, sum_r)) print(ans) if __name__=='__main__': main()
p02597
s613847465
Wrong Answer
n=int(input()) s=[c for c in input()] left=0 right=n-1 ans=0 while left<n and s[left]=='W': while left<right and s[right]=='W': right-=1 if left==right: break s[left]='R' s[right]='W' ans+=1 left+=1 while left<n and s[left]=='R': left+=1 for i in range(left,n-1): if s[i]=='W' and s[i+1]=='R': s[left]='R' s[i+1]='W' left+=1 ans+=1 print(ans)
p02597
s865021346
Wrong Answer
n = int(input()) c = input() wc = c.count('W') rc = c.count('R') print(min(c[rc-1:].count('R'), c[:wc].count('W'), n-rc, n-wc))
p02597
s130614033
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
s698515477
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 res = 0 if r == 0 or w == 0: print(0) exit() elif w < r: ans += r - w r = w ans += r - l print(ans)
p02597
s101611541
Wrong Answer
N = int(input()) C = list(input()) N1 = int(N/2) C1 = C[0:N1] C2 = C[N1:N] print(C1) print(C2) count = 0 if (C1.count('W') == C2.count('R')): #左右対象のとき count = C1.count('W') else: count = C.count('W') print(count)
p02597
s383611598
Wrong Answer
import sys N = int(input()) c = list(input()) #print(c) myr_cnt = c.count('R') if myr_cnt == 0: print(1) sys.exit() #print(myr_cnt) myw_cnt = 0 for i in range(myr_cnt): if c[i] == 'W': myw_cnt += 1 print(myw_cnt)
p02597
s044886847
Wrong Answer
n = int(input()) c = str(input()) # c = [1 if i == 'R' else 0 for i in input()] cnt = 0 while 'WR' in c: c = c.replace('WR', 'RR', 1) idx = c.rfind('R') c = c[:idx] + 'W' + c[idx+1:] cnt += 1 print(cnt)
p02597
s910114783
Wrong Answer
n = int(input()) s = input() wc = s[:n//2].count('W') rc = s[n//2:].count('N') # print(wc) # print(rc) print(max(wc, rc))
p02597
s408861095
Wrong Answer
N=int(input()) c=list(input()) k=0 for i in range(N): if c[i]!='R': k=i break R=c[k:].count('R') W=c[k:k+R+1].count('W') if c.count('W')==N: W=N print(W)
p02597
s591653381
Wrong Answer
N = int(input()) S = input() def calculate(n, s): arr = list(s) result = [] leftW = 0 rightR = arr.count('R') for i in range(n): val = arr[i] if val == 'R': rightR -= 1 if val == 'W': leftW += 1 result.append(max(leftW,rightR)) if len(result) == 0: print(0) else: print(min(result)) calculate(N, S)
p02597
s092864474
Wrong Answer
n = int(input()) A = list(input()) if A.count('R')==n: print(0) elif A.count('W')==n: print(0) else: cnt = max(A[:0].count('W'),A[0:].count('R')) mini = cnt for i in range(1,n-1): if A[i] == 'W': cnt += 1 else: cnt -= 1 mini = min(cnt,mini) print(mini)
p02597
s524382880
Wrong Answer
n = int(input()) c = input() ans = 0 c1 = len(c)//2 cnt_w = 0 cnt_r = 0 for i in range(c1): if c[i]=='W': cnt_w += 1 for i in range(c1,len(c)): if c[i]=='R': cnt_r += 1 ans = cnt_w if cnt_w <= cnt_r else cnt_r print(ans)
p02597
s083578700
Wrong Answer
import math N=int(input()) c=input() if c.count("R")==0 or c.count("W")==0: print(0) else: W_count=0 R_count=0 for i in range(math.ceil(N/2)): if c[i]=="W": W_count+=1 else: R_count+=1 print(min(c.count("R"),c.count("W"),max(W_count,R_count)))
p02597
s417161395
Wrong Answer
#!/usr/bin/env python3 import time k = int(input()) s = '' rs = [] start = time.time() cnt = 0 while True: cnt += 1 s += '7' n = int(s) r = n%k if r==0: print(cnt) exit() if r in rs: print(-1) end = time.time() exit() rs.append(r) end = time.time() t = end-start if t >= 1.8: print(k-1) exit()
p02597
s132842348
Wrong Answer
N=int(input()) C=list(input()) nR=-1 nW=0 u=0 for i in range(N): if C[i]=='W': nW=nW+1 else: u=i break if u!=0: for i in range(N-u): if C[i+u]=='R': nR=nR+1 if nW<=nR: print(nR) if nW>nR: print(nR+1)
p02597
s667644200
Wrong Answer
import collections as c n = int(input()) s = list(input()) mr = s.count("R") mw = s.count("W") cnt = 0 r = 0 w = 0 for i in s: if w>=mr-r: print(cnt) break if i == "R": r += 1 else: w += 1 cnt += 1
p02597
s393719495
Wrong Answer
N=int(input()) c=list(str(input())) ans=0 wl=0 for r in range(N-1,-1,-1): if r=='W': print('a') continue for w in range(wl,r): if c[w]=='W': c[w],c[r]='R','W' wl=w+1 ans+=1 break print(ans)
p02597
s943233543
Wrong Answer
k = int(input()) s = list(input()) count=0 for i in range(int(k/2)): if s[i]=="W": count+=1 print(count)
p02597
s057702050
Wrong Answer
n=int(input()) s=input() cntw=[0]*(n+1) totr=0 totw=0 for i in range(n): if s[i]=='W': cntw[i+1]=cntw[i]+1 totr+=1 else: cntw[i+1]=cntw[i] totw+=1 ans=10**6 for i in range(n+1): w=cntw[i] r=n-i-(totw-cntw[i]) ans=min(ans,max(w,r)) print(ans)
p02597
s069895161
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) + 1 - right_r res = min(left_w, right_r) if right_r and not left_w: print(min(right_w, right_r)) else: print(res)
p02597
s086041541
Wrong Answer
n = int(input()) c = input() _trigger = False ans = 0 _count = c.count('R') for i in range(n): if c[i] == 'W': _trigger = True else: if _trigger and i + 1 >= _count: ans += 1 print (ans)
p02597
s400812199
Wrong Answer
N = int(input()) a = input() wc = int(0) rc = int(0) c = int(0) for i in range(N): if a[i] == "W": wc += 1 else: rc += 1 if rc == 0: print("0") else: for i in range(rc): if a[i] == "W": c += 1 print(c)
p02597
s864693599
Wrong Answer
n = int(input()) c = input() if len(c) % 2 == 0: w_count = c[:len(c)//2].count("W") r_count = c[len(c)//2:].count("R") else: w_count = c[:len(c)//2 + 1].count("W") r_count = c[len(c)//2:].count("R") if (w_count == 0)|(r_count==0): print(0) else: print(w_count) if w_count < r_count else print(r_count)
p02597
s946881466
Wrong Answer
# N = 8 # S = "WRWWRWRR" # # N = 2 # S = "RR" # # N = 4 # S = "WWRR" N = int(input()) S = input() def calculate(n, s): arr = list(s) RNum = arr.count("R") leftW = 0 rightR = RNum result = [] for i in range(n): if arr[i] == "R": rightR -= 1 if arr[i] == "W": leftW += 1 result.append(max(leftW, rightR)) print(min(result)) calculate(N, S)
p02597
s585539727
Wrong Answer
N = int(input()) RW = input() j = N-1 count = 0 for i in range(N//2): if RW[i]=='W': while i<j: if RW[j]=='R': count += 1 break j -= 1 print(count)
p02597
s325432521
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
s181334267
Wrong Answer
N = int(input()) C = list(input()) W = 0 R = 0 for i in range(0,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
s263952027
Wrong Answer
n = int(input()) s = input() res = 2000000 #aw=s.count('W') ar=s.count('R') pw=0 pr=0 for i in range(n-1): if (s[i] == 'R'): pr=pr+1 else: pw=pw+1 if (max(pw,ar-pr) < res): res = max(pw,ar-pr) print(str(res))
p02597
s396377569
Wrong Answer
from collections import Counter import sys n = int(input()) c = input() s = Counter(c) if s['W'] == 0 or s['R'] == 0 or c.index('R') == 0 and c.index('W') == s['R']: print('0') sys.exit() r = s['R'] las_pos=0 count = 0 for i, v in enumerate(c): if v == 'R': if i - las_pos < r: r = r - (i - las_pos + 1) count += (i - las_pos) las_pos = i else: count += r break print(count)
p02597
s667394946
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: if c[half] == 'R': ans = ans +1 print(ans-1)