problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02958
s372280658
Accepted
n = int(input()) p = list(map(int,input().split())) count = 0 for i in range(n-1): if(p[i] != i+1): count += 1 if(count <= 2): print("YES") else: print("NO")
p03852
s958797115
Accepted
c=input() A=['a','e','i','o','u'] if c in A: print("vowel") else: print("consonant")
p02916
s413220755
Accepted
N = int(input()) A = list(map(int,input().split())) A.append(-1) B = list(map(int,input().split())) C = list(map(int,input().split())) ret = 0 for i in range(N): ret += B[A[i]-1] + C[A[i]-1] if A[i+1] == A[i]+1 else B[A[i]-1] print(ret)
p03282
s335399940
Accepted
a = input() k = int(input()) b = list(a) if k == 1: print(b[0]) exit() else: for i in range(k): if int(b[i]) != 1: print(b[i]) exit() print(1)
p02683
s813351893
Wrong Answer
N, M, X = map(int, input().split()) A = [list(map(int, input().split())) for i in range(N)] final = 1000000000 for i in range(1, N ** 2): ans = 0 rikai = [0]*M for j in range(N): if ((i >> j) & 1): for k in range(1, M+1): rikai[k-1] += A[j][k] ans += A[j][0] if all(el >= X for el in rikai): final = min(final, ans) if final == 1000000000: print(-1) else: print(final)
p02596
s590011655
Accepted
K=int(input()) X=[0]*K m=0 p=7 for i in range(K): m=(m+p)%K if m==0: print(i+1) break elif X[m]==1: print(-1) break else: X[m]=1 p=(p*10)%K
p02972
s546671967
Accepted
n=int(input()) a=list(map(int,input().split())) b=[0]*n for i in range(n-1,-1,-1): b[i]=(a[i]+sum(b[i::i+1]))%2 l=[x+1 for x,y in enumerate(b) if y==1] print(len(l)) print(*l)
p02939
s597058840
Accepted
s = input() #sが2文字以下の場合は要素数 if len(s)<=2: print(len(set(list(s))));exit() #dp[i]はsをi-1文字目まで見た時の分割の最大数 dp=[0]*(len(s)+1) dp[0]=0 dp[1]=1 dp[2]=(len(set(list(s[:2])))) #4文字目からスタート for i in range(3,1+len(s)): if s[i-1]!=s[i-2]: dp[i]=dp[i-1]+1 else: dp[i]=dp[i-3]+2 print(dp[-1])
p03241
s671766234
Accepted
n, m = map(int, input().split()) def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) divisors.sort() return divisors div = make_divisors(m) for i in div[::-1]: if i <= m / n: print(i) break
p02953
s760262300
Accepted
from collections import deque N = int(input()) H = deque(map(float, input().split())) ato = H.pop() if N == 1: print('Yes') exit() for i in range(N-1, 0, -1): mae = H.pop() if ato - mae < -1: print('No') exit() elif ato - mae == -1: ato = mae - 1 else: ato = mae print('Yes')
p03069
s006945844
Accepted
N = int(input()) S = input() n = S.count('.') ans = min(n, N-n) lsc = 0 rsc = N-n for i, c in enumerate(S): if c == '#': lsc += 1 rsc -= 1 a = lsc + ((N-i-1) - rsc) ans = min(ans, a) print(ans)
p02705
s530804006
Accepted
# A - Circle Pond import math import sys def main(): R = int(input()) print(2 * math.pi * R) sys.stderr.write("debug") if __name__ == "__main__": main()
p03254
s063924614
Wrong Answer
N, x = [int(x) for x in input().split()] a = sorted([int(x) for x in input().split()]) ans = 0 if sum(a) <= x: ans = N - 1 elif sum(a) == x: ans = N else: for i in range(N): if x >= a[i]: x -= a[i] ans += 1 print(ans)
p03417
s840947984
Accepted
n,m = map(int,input().split()) if n == m == 1: print(1) elif n == 1: print(m-2) elif m == 1: print(n-2) elif n == 2 or m == 2: print(0) else: print(n*m -(n+m-2)*2)
p02657
s013761469
Wrong Answer
from math import floor as f
p03077
s872196395
Wrong Answer
info=[] for _ in range(6): info.append(int(input())) ans=5+info[0]//min(info[1:]) print(ans)
p02760
s795315443
Accepted
import sys a1=[int(i) for i in input().split()] a2=[int(i) for i in input().split()] a3=[int(i) for i in input().split()] for l in sys.stdin: if int(l) in a1: a1[a1.index(int(l))]=0 elif int(l) in a2: a2[a2.index(int(l))]=0 elif int(l) in a3: a3[a3.index(int(l))]=0 m=sum(a1)*sum(a2)*sum(a3) for i in range(3): m*=a1[i]+a2[i]+a3[i] m*=a1[i]+a2[1]+a3[2-i] print('Yes' if m==0 else 'No')
p03371
s176033279
Accepted
a, b, c, x, y = map(int,input().split()) min_xy = min(x, y) max_xy = max(x, y) min_xy_cost = min(a + b, c * 2) * min_xy if x >= y: rest = x - y rest_cost = rest * min(a, c * 2) else: rest = y - x rest_cost = rest * min(b, c * 2) total = min_xy_cost + rest_cost print(total)
p03556
s810949813
Accepted
N = int(input()) ans = 0 for n in range(N+1): if n*n <= N: ans = n*n else: break print(ans)
p03994
s109936671
Accepted
s=input() k=int(input()) ans="" for i in s[:-1]: if i=="a": ans+=i continue if k>=123-ord(i): k-=123-ord(i) ans+="a" else: ans+=i i=s[-1] ans+=chr((ord(i)+k-97)%26+97) print(ans)
p03062
s354694171
Wrong Answer
# coding: utf-8 import sys import numpy as np sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N = ir() A = np.array(lr()) if np.count_nonzero(A) != len(A): answer = np.abs(A).sum() else: negative = np.count_nonzero(A < 0) if negative%2 == 0: answer = np.abs(A).sum() else: answer = np.abs(A).sum() answer -= 2 * min(np.abs(A[0]), np.abs(A[-1])) print(answer) # 37
p02789
s736957808
Accepted
n,m=map(int,input().split()) if n==m: print('Yes') else: print('No')
p03493
s474297282
Accepted
print(str(input()).count("1"))
p02583
s723926679
Wrong Answer
def solve(): N = int(input()) L = list(map(int, input().split())) count = 0 for i in range(N): for j in range(i+1, N): for k in range(j+1, N): if(L[i] != L[j] and L[j] != L[k] and L[k] != L[i]): if(L[i]+L[j] > L[k] and L[j]+L[k] > L[i] and L[k]+L[i] > L[j]): count += 1 print(count)
p02661
s128467861
Accepted
N = int(input()) l, r = [0 for _ in range(N)], [0 for _ in range(N)] for i in range(N): l[i], r[i] = map(int, input().split()) if N%2 == 1: lm = sorted(l)[(N+1)//2-1] rm = sorted(r)[(N+1)//2-1] print(rm - lm + 1) else: lm = sum(sorted(l)[N//2-1:N//2+1])/2 rm = sum(sorted(r)[N//2-1:N//2+1])/2 # 0.5 刻みで増えることに注意 print(int((rm-lm+0.5)*2))
p02571
s476948838
Accepted
s=input() t=input() slen=len(s) tlen = len(t) min = tlen for i in range(slen - tlen + 1): count = 0 for j in range(tlen): if s[i + j] != t[j]: count += 1 if count < min: min = count print(min)
p02695
s411433706
Accepted
import itertools n,m,q = map(int,input().split()) a = [];b = []; c = []; d = [] for i in range(q): u,x,y,z = map(int,input().split()) a.append(u) b.append(x) c.append(y) d.append(z) ans = 0 for A in itertools.combinations_with_replacement(range(1,m+1),n): score = 0 for i in range(q): if A[b[i]-1] - A[a[i]-1] == c[i]: score += d[i] ans = max(score,ans) print(ans)
p03077
s490971275
Accepted
import math n=int(input()) l=[int(input()) for i in range(5)] print(4+math.ceil(n/min(l)))
p03339
s016331586
Accepted
import sys readline = sys.stdin.readline def main(): N = int(readline()) S = readline().rstrip() e_right = S.count('E') w_left = 0 res = N for i in range(N): if S[i] == 'E': e_right -= 1 res = min(res, e_right + w_left) else: res = min(res, e_right + w_left) w_left += 1 print(res) if __name__ == '__main__': main()
p02663
s848301140
Accepted
a,b,c,d,e=map(int,input().split()) n=(c-a)*60+(d-b) print(n-e)
p03838
s519653365
Wrong Answer
x,y = map(int,input().split()) ans = 0 if x*y < 0: ans += 1 elif y < x: ans += 2 ans += abs(abs(x)-abs(y)) if x<y: ans = min(y-x,ans) print(ans)
p02687
s467233330
Accepted
s = input() if s == 'ABC': print('ARC') if s == 'ARC': print('ABC')
p03721
s859280305
Accepted
N,K=map(int,input().split()) C=[0]*(10**5+1) for i in range(N): a,b=map(int,input().split()) C[a]+=b cnt=0 l=0 while cnt<K: l+=1 cnt+=C[l] print(l)
p02922
s153221649
Accepted
import sys a, b = map(int, sys.stdin.readline().split()) print(-((a-b) // (a-1)) + 1)
p02848
s400692417
Wrong Answer
n = int(input()) s = input() t = [] for i in range(len(s)): t += chr(((ord(s[i])-65+n)%26)+65) ''.join(t) print(t)
p04011
s778845395
Accepted
n = int(input()) k = int(input()) x = int(input()) y = int(input()) if n > k: print(k*x+y*(n-k)) else: print(n*x)
p02555
s585469770
Accepted
P = 10**9 + 7 S = int(input()) ans = [0]*(S + 1) for i in range(3, S + 1): ans[i] = 1 for i in range(6, S + 1): for j in range(3, i - 2): ans[i] = (ans[i] + ans[j]) % P print(ans[S])
p03146
s824472557
Wrong Answer
s = int(input()) n = 2 ss = set() while True: if s % 2 == 0: s //= 2 else: s = 3 * s + 1 if s in ss: break ss.add(s) n += 1 print(n)
p03339
s971984490
Accepted
N = int(input()) S = list(input()) we = [] west = 0 east = 0 for i in range(N): if S[i] == "W": west += 1 elif S[i] == "E": east += 1 we.append([west,east]) ans = 1e9 for i in range(N): if i == 0: left = 0 else: left = we[i][0] right = we[N-1][1] - we[i][1] ans = min(ans,left+right) print(ans)
p02775
s129681824
Wrong Answer
n = int(input()) ans = 0 n_dig = len(str(n)) # Nの桁数 carry = 0 for i in range(n_dig): d = n % 10 n //= 10 if carry + d <= 5: ans += d + carry carry = 0 # 繰り上がり else: ans += 10 - d - carry carry = 1 print(ans + carry)
p03612
s255022380
Accepted
input() c = [0] for i, pi in enumerate(map(int, input().split())): if i + 1 == pi: c[-1] += 1 else: c.append(0) print(sum((i + 1) // 2 for i in c))
p03329
s514701934
Wrong Answer
from collections import deque n=int(input()) q=deque([[1,1],[6,1],[9,1]]) b=set() while q: a=q.popleft() if a[0] in b: continue b.add(a[0]) if a[0]==n: print(a[1]) break if a[0]>n: continue q.append([a[0]+1,a[1]+1]) for i in range(10): q.append([a[0]+6**i,a[1]+1]) q.append([a[0]+9**i,a[1]+1])
p03479
s060361305
Accepted
import sys def resolve(): readline = sys.stdin.readline # 1行だけ文字列にする X, Y = map(int, readline().split()) # Ai+1 = 2Aiとすればおk? A = X cnt = 1 while 1: A = 2 * A if A <= Y: cnt += 1 else: print(cnt) break resolve()
p03481
s931341857
Accepted
x, y = map(int, input().split()) ans = 0 while x <= y: x *= 2 ans += 1 print(ans)
p02842
s233531879
Wrong Answer
N = int(input()) for x in range(1,10000): if int(x*1.08)==N: print(x) break if x==9999: print(":(")
p03745
s443343811
Accepted
def check(a,b): if a<b: return 'up' if a>b: return 'down' return '' def solve(): ans = 1 N = int(input()) A = list(map(int, input().split())) ud = '' for i in range(N-1): a = check(A[i],A[i+1]) if ud=='' or ud==a: ud = a continue if a=='': continue ans += 1 ud = '' return ans print(solve())
p02958
s258079886
Accepted
N = int(input()) p = list(map(int, input().split())) p_sort = sorted(p) ans = 0 for i in range(len(p)): if p[i] != p_sort[i]: ans += 1 if ans <= 2: print("YES") else: print("NO")
p02742
s060085722
Accepted
import sys h,w = map(int, input().split()) all = h*w if h == 1 or w == 1: print(1) sys.exit() if all % 2 == 0: ans = all//2 else: ans = all//2+1 print(ans)
p03644
s455413514
Wrong Answer
N = int(input()) a=2 while a < N: a*=2 print(int(a/2))
p03284
s966672645
Wrong Answer
n, k = map(int, input().split()) print(n % k)
p03438
s025897691
Accepted
n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) sum_a = sum(a) sum_b = sum(b) if sum_a <= sum_b: cnt = 0 for i in range(n): if a[i] > b[i]: cnt += a[i] - b[i] elif a[i] < b[i]: cnt -= (b[i] - a[i]) // 2 if cnt <= 0: print("Yes") else: print("No") else: print("No")
p02693
s017366739
Wrong Answer
K = int(input()) a,b = map(int,input().split()) c = 'NG' for i in range(a,b+1): if i % K == 0: c = 'OK' break print(c)
p04045
s203435376
Wrong Answer
import itertools N, K = list(map(int, input().split())) D = set(input().split()) diff = set([str(n) for n in range(10)]) - D lenN = len(str(N)) + 1 lists = list(itertools.product(list(diff), repeat=lenN)) lists = sorted([int("".join(l)) for l in lists]) for l in lists: if l >= N: print(l) break
p03637
s753281534
Accepted
n=int(input()) a=list(map(int,input().split())) fcount=0 tcount=0 for i in range(n): if a[i]%4==0: fcount+=1 elif a[i]%2==0: tcount+=1 ocount=n-(fcount+tcount) if fcount+tcount>=n: print("Yes") elif ocount<=n//2 and ocount<=fcount: print("Yes") elif n%2!=0 and fcount>=n//2: print("Yes") else: print("No")
p02646
s216493713
Accepted
numsA = [int(e) for e in input().split()] numsB = [int(e) for e in input().split()] T = int(input()) if abs(numsA[0]-numsB[0])<=(numsA[1]-numsB[1])*T: print("YES") else: print("NO")
p03137
s185647421
Accepted
N,M=map(int,input().split()) X=sorted(list(map(int,input().split()))) print(sum(sorted([X[i+1]-X[i] for i in range(M-1)])[::-1][N-1:]))
p03474
s778247370
Accepted
A,B=map(int,input().split()) S=input() print('Yes' if S[A]=='-' and S[:A].isdecimal() and S[A+1:].isdecimal() else 'No' )
p02854
s746096533
Wrong Answer
def myAnswer(N:int,A:list) -> int: ans = 10**9 for i in range(1,N): tmp = abs(sum(A[:i]) -sum( A[i:])) ans = min(tmp,ans) return ans def modelAnswer(): tmp=1 def main(): N = int(input()) A = list(map(int,input().split())) print(myAnswer(N,A[:])) if __name__ == '__main__': main()
p03385
s154333606
Accepted
print("Yes" if len(set(input()))==3 else "No")
p02862
s464183898
Wrong Answer
x, y = map(int, input().split()) mod = 10 ** 9 + 7 dif = abs(x - y) num = min([x, y]) - dif if num % 3 != 0: print(0) exit() num = num / 3 * 2 + dif ans = 1 for i in range(int(num)): ans = ans * (i + 1) % mod print(ans % mod)
p03433
s904068927
Wrong Answer
N = int(input()) A = int(input()) total = N for i in range(1, 10000): if total - 500*i == 0: print('Yes') break elif total - 500*i < 0: total = total - 500*(i - 1) break if total - A > 0: print('No') else: for j in range(A): total = total - 1 if total == 0: print('Yes') break
p03281
s490309315
Wrong Answer
N = int(input()) if N >= 189: print(3) elif 189 > N >= 135: print(2) elif 135 > N >= 105: print(1) else: print(0)
p04031
s056853613
Accepted
N = int(input()) a = list(map(int, input().split())) x = 100 count1 = 0 for i in a: count1 += (i - x)**2 for X in range(-100, 100): count = 0 for i in a: count += (i - X)**2 if count < count1: count1 = count print(count1)
p02629
s779924950
Accepted
n=int(input()) name="" for i in range(15): n=n-1 name=name+chr(97+n%26) n=n//26 if n==0: break print(name[::-1])
p03592
s884885402
Accepted
n,m,k = map(int,input().split()) for i in range(n+1): for j in range(m+1): if i*m+j*n-2*i*j == k: print("Yes") exit() print("No")
p04044
s198753838
Accepted
N,L = map(int,input().split()) S = [] for i in range(N): S.append(input()) sorted_S = sorted(S) print(*sorted_S,sep='')
p02958
s027173214
Wrong Answer
N = int(input()) p = list(map(int, input().split())) count = 0 for i in range(0, N - 1): if p[i + 1] != i + 2: count += 1 print("NO") if count > 2 else print("YES")
p02731
s031128650
Wrong Answer
N = int(input()) # print(Decimal(N) // Decimal(3)) print(round(N//3, 12))
p02766
s435482331
Accepted
n,k = map(int, input().split()) cnt=0 while(n>=1): n /= k cnt += 1 print(cnt)
p03693
s295267886
Accepted
import sys input = sys.stdin.readline r,g,b = [int(i) for i in input().split()] d = 10 * g + b if d % 4 == 0 : print("YES") else : print("NO")
p03803
s376766889
Accepted
a, b = map(int, input().split()) if a == b: print('Draw') elif a == 1: print('Alice') elif b == 1: print('Bob') elif a < b: print('Bob') else: print('Alice')
p03380
s442005915
Wrong Answer
import bisect n,*a=map(int,open(0).read().split()) a=sorted(a) m=a[-1] l=bisect.bisect_left(a,(m+1)//2) r=bisect.bisect_right(a,(m+1)//2) if abs(2*a[l]-1-m)<=abs(2*a[r]-1-m): k=a[l] else: k=a[r] if len(a)==2: k=a[0] print(m,k)
p02795
s498095268
Wrong Answer
h = int(input()) w = int(input()) n = int(input()) cell_cnt=0 x=0 for x in range(h): cell_cnt+=w if cell_cnt>=n: break print(x+1)
p04011
s668915331
Wrong Answer
N = int(input()) K = int(input()) X = int(input()) Y = int(input()) print(N*X + (N-K)*Y)
p02713
s575452593
Accepted
import math K = int(input()) ans = 0 for i in range(1,K+1): for j in range(1,K+1): for k in range(1,K+1): ans += math.gcd(math.gcd(i,j),k) print(ans)
p02813
s759600223
Accepted
import itertools import math N = int(input()) P = list(map(int, input().split())) Q = list(map(int, input().split())) L = list(map(list,list(itertools.permutations(list(i for i in range(1,N+1)),N)))) a = L.index(P) b = L.index(Q) print(abs(a-b))
p03386
s492422770
Wrong Answer
if __name__ == "__main__": a, b, k = map(int, input().split()) output = dict() for i in range(k): if a<= a+i <= b: output[a+i] = a+i for i in range(-k+1,1): if a<= b+i <= b: output[b+i] = b+i for o in output.keys(): print(o)
p02689
s951067687
Accepted
N,M = map(int, input().split()) H = list(map(int, input().split())) L = [] for i in range(M): a, b = map(int, input().split()) if H[a-1] > H[b-1]: L.append(b-1) elif H[a-1] < H[b-1]: L.append(a-1) else: L.append(a-1) L.append(b-1) print(N - len(set(L)))
p02572
s055158124
Wrong Answer
n = int(input()) a = list(map(int,input().split())) a2 = [i*i for i in a] S = int((sum(a) * sum(a) - sum(a2))/2) print(int(S % (1000000007)))
p03472
s217147824
Wrong Answer
n,h=map(int,input().split()) X=[] for i in range(n): a,b=map(int,input().split()) X.append([a,-b]) X.sort(key=lambda x:x[0],reverse=True) Y=X[1:] Y.sort(key=lambda x:x[1],reverse=True) cnt=0 for i in range(n-1): if Y[i][1]<=X[0][1]: h+=Y[i][1] cnt+=1 if h<=0: break if h>0: h+=X[0][1] cnt+=1 if h>0: cnt+=h//X[0][0] print(cnt)
p03760
s865154288
Accepted
o = input() e = input() ans = '' for i in range(len(e)): ans += o[i]+e[i] print(ans if len(o)==len(e) else ans+o[-1])
p03695
s539044069
Accepted
N = int(input()) A = list(map(int, input().split())) A = map( lambda x:x//400, A) A = list(map( lambda x:x if x<8 else 8, A)) cnt8 = A.count(8) A = list(set(A)) if 8 in A: A.remove(8) sum = len(A) if sum == 0: print(1, end=' ') else: print(sum, end=' ') sum += cnt8 print(sum)
p02606
s008882066
Accepted
L,R,d = map(int, input().split()) a = 0 for i in range(L,R+1): if(i%d==0): a+=1 print(a)
p02612
s909976664
Accepted
a=int(input()) a%=1000 if a==0: print(0) else: print(1000-a)
p02546
s370999182
Wrong Answer
S = input() print(S[-1]) if S[-1] == 's': print(S + 'es') else: print(S + 's')
p03592
s850400193
Accepted
N,M,K=map(int,input().split()) F=False for x in range(N+1): for y in range(M+1): F|=(x*(M-y)+y*(N-x)==K) if F: print("Yes") else: print("No")
p02706
s291644059
Accepted
n,m = map(int,input().split()) hwd = list(map(int,input().split())) s = sum(hwd) print(n-s) if n >= s else print(-1)
p02646
s160508128
Accepted
import sys a, v = map(int, input().split()) b, w = map(int, input().split()) t = int(input()) if v <= w: print('NO') sys.exit() time = abs((a-b)/(v-w)) if t<time: print('NO') else: print('YES')
p03377
s844984102
Accepted
a, b, x = map(int, input().split()) if a <= x < a+b: print("YES") else: print("NO")
p02993
s230697533
Accepted
s = list(input()) # print(s) if s[0] != s[1] and s[1] != s[2] and s[2] !=s [3]: print('Good') else: print('Bad')
p03206
s043524921
Accepted
d = 25 - int(input()) s = 'Christmas' for i in range(d): s += ' Eve' print(s)
p02547
s706697739
Accepted
n = int(input().rstrip()) cnt = 0 flg = False d_list = [[0, 0] for i in range(n)] for i in range(n): d_list[i] = list(map(int, input().rstrip().split(" "))) for ds in d_list: if ds[0] == ds[1]: cnt += 1 else: cnt = 0 if cnt >= 3: flg = True break if flg: print("Yes") else: print("No")
p03338
s217698450
Accepted
N = int(input()) S = list(input()) #%% ans= 0 for i in range(1,N): set1 = set() set2 = set() for s in S[:i]: set1.add(s) for s in S[i:]: set2.add(s) sets = set1 & set2 ans = max(ans,len(list(sets))) print(ans)
p04033
s630176300
Wrong Answer
W=list(map(int,input().split())) ne=0 if 0 in W: print("Zero") exit() else: for i in range(len(W)): if W[i]<0: ne+=1 if ne%2==0: print("Positive") else: print("Negative")
p02933
s331465231
Accepted
a=int(input()) s=str(input()) if a>=3200: print(s) else: print("red")
p03323
s830406943
Wrong Answer
a, b = map(int, input().split()) if a or b > 8: print('Yay!') else: print(':(')
p02627
s171612576
Accepted
s = input() alpha = ["q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","z","x","c","v","b","n","m"] if s in alpha: print("a") else: print("A")
p02701
s632563930
Accepted
N = int(input()) S = [input() for i in range(N)] print(len(set(S)))
p02597
s824922999
Accepted
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N = int(input()) Cs = list(input()) from collections import deque Q = deque() for i, c in enumerate(Cs): if c=='R': Q.append(i) ans = 0 for i in range(N): c = Cs[i] if c=='W': if not Q: break r = Q.pop() if r>i: ans += 1 else: break print(ans)
p02607
s953575410
Accepted
import math N=int(input()) a=list(map(int,input().split())) ans=0 for i in range(N): if (i%2==0)and(a[i]%2!=0): ans+=1 #print(i,end='=>') #print(a[i]) print(ans)