problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02971
s987389172
Wrong Answer
n =int(input()) a =[int(input()) for _ in range(n)] new_a=sorted(a) first_max =new_a[-1] second_max =new_a[-2] for i in a: print(i) if i ==first_max: print(second_max) else: print(first_max)
p02553
s116723788
Accepted
a,b,c,d=map(int,input().split()) A=a*c B=a*d C=b*c D=b*d N=[A,B,C,D] print(max(N))
p03455
s335331157
Accepted
a, b = map(int, input().split()) print("Even") if (a * b) % 2 == 0 else print("Odd")
p03059
s851282796
Wrong Answer
def mapt(fn, *args): return tuple(map(fn, *args)) def Input(): return mapt(int, input().split(" ")) def main(): a, b, k = Input() ans = 0 for i in range(1, k, a): ans += b print(ans) main()
p02832
s796779104
Wrong Answer
n = int(input()) la = [int(w) for w in input().split()] ans = 0 i = 1 for a in la: if a != i: ans += 1 else: i += 1 print(ans)
p03827
s726165440
Wrong Answer
n=int(input()) s=input() t=0 m=-1 for i in range(len(s)): if s[i]=="I": t+=1 else: t-=1 if m<t: m=t print(m)
p03417
s194551960
Wrong Answer
N, M = map(int, input().split()) n = min(N, M) m = max(N, M) if n == 1: print(max(m-2, 0)) elif n == 2: print(0) else: print((n-2)*(m-2))
p02793
s150660703
Accepted
from fractions import gcd def lcm(a, b): return a * b // gcd(a, b) def mod_inv(a, m): return pow(a, m-2, m) MOD = 10 ** 9 + 7 N = int(input()) A = list(map(int, input().split())) _lcm = 1 for a in A: _lcm = lcm(_lcm, a) ans = _lcm * sum([mod_inv(s, MOD) for s in A]) % MOD print(int(ans % MOD))
p03673
s145047030
Accepted
#!/usr/bin/env python3 n = int(input()) a = input().split() ans = a[0::2][::-1] + a[1::2] if n % 2: print(*ans) else: print(*ans[::-1])
p02697
s962690427
Accepted
n, m = map(int, input().split()) if n % 2 == 1: for i in range(1, m+1): print(i, n - i) else: for i in range(1, min(n//4+1, m+1)): print(i, n - i + 1) for i in range(n//4+1, m+1): print(i, n - i)
p03000
s956240607
Wrong Answer
import bisect as bi I=lambda:list(map(int,input().split())) n,x=I() l=I() ans=0 t=0 for i in range(1,n): l[i]+=l[i-1] an=bi.bisect(l,x) print(an)
p02547
s750814217
Accepted
n=int(input()) l=[list(map(int,input().split())) for i in range(n)] cnt=0 for i in range(n-2): if (l[i][0]==l[i][1]) and (l[i+1][0]==l[i+1][1]) and (l[i+2][0]==l[i+2][1]): print("Yes") exit() print("No")
p03854
s022203697
Wrong Answer
S = input() # Greedyアルゴリズム S = S[::-1] print(S) S = S.replace("resare","") S = S.replace("esare","") S = S.replace("remaerd","") S = S.replace("maerd","") if S == "": print("YES") else: print("NO")
p04045
s614402845
Wrong Answer
N, L = map(int, input().split()) hates = list(map(str, input().split())) for i in range(N, 10000): nums = list(str(i)) com = set(nums) & set(hates) if len(com) == 0: print(i) break
p03262
s857551994
Accepted
#!/usr/bin/env python3 n,x = map(int,input().split()) a = list(map(int,input().split())) def gcd(a,b): if b > a: a,b = b,a while b > 0: #print(a,b) a,b = b,a%b return a cur_gcd = abs(x-a[0]) a.sort() for i in range(n-1): cur_gcd = gcd(cur_gcd,abs(x-a[i+1])) #print(cur_gcd) print(cur_gcd)
p03243
s478671827
Accepted
n = list(str(input())) if int(''.join([n[0],n[0],n[0]])) < int(''.join(n)): print(int(''.join([n[0],n[0],n[0]]))+111) else: print(int(''.join([n[0],n[0],n[0]])))
p03699
s536437526
Accepted
n = int(input()) s = [int(input()) for i in range(n)] s.sort() ans = sum(s) if (ans % 10 != 0): print(ans) else: for i in s: if (i % 10 != 0): print(ans - i) break else: print(0)
p03773
s142179518
Accepted
a, b = map(int, input().split()) c = a+b if c >= 24: print(c-24) else: print(c)
p03448
s910349775
Accepted
a,b,c,x = map(int,[input() for i in range(4)]) ans = 0 for i in range(a+1): for j in range(b+1): for k in range(c+1): if i * 500 + j * 100 +k * 50 == x: ans += 1 print(ans)
p02732
s277943814
Accepted
from collections import Counter def comb(x): return x*(x-1)//2 n = int(input()) a = list(map(int,input().split())) c = Counter(a) b = 0 for i in c.values(): b+=comb(i) for k in range(n): print(b-c[a[k]]+1)
p02706
s994605841
Accepted
N,M = map(int,input().split()) List = list(map(int,input().split())) if sum(List) > N: print(-1) else: print(N-sum(List))
p03699
s215931400
Wrong Answer
import sys import copy import math import itertools import numpy as np import re N = int(input()) s = [int(input()) for c in range(N)] s = sorted(s) ans = sum(s) for i in range(N): if ans % 10 ==0: ans -= s[i] else: print(ans) sys.exit(0) print(0)
p03943
s052773319
Accepted
l=list(map(int,input().split())) a=l[0] b=l[1] c=l[2] if a+b==c or b+c==a or c+a==b: print("Yes") else: print("No")
p02570
s031283955
Accepted
D, T, S = map(int, input().split()) if(T >= D/S): print('Yes') else: print('No')
p03069
s779029246
Wrong Answer
n = int(input()) s = input() + '#' idx = s.index('#') cnt = 0 for i in range(idx + 1, n): if s[i] == '.': cnt += 1 res1 = cnt res2 = s.count('.') res3 = s[:n].count('#') print(min(res1, res2, res3))
p02793
s983886309
Accepted
import fractions N = int(input()) A = list(map(int, input().split())) def lcm(x, y): return (x * y) // fractions.gcd(x, y) def solve(): memo = A[0] for i in range(1, N): memo = lcm(memo, A[i]) ans = 0 for i in range(N): ans += memo // A[i] return ans % (10 ** 9 + 7) print(solve())
p02730
s276017033
Accepted
s = input() s=list(s) N=len(s) def check(s): n=len(s) if n%2==1: lefts=s[:n//2] rights=s[n//2+1:] else: lefts=s[:n//2] rights=s[n//2:] if lefts!=rights[::-1]: return False else: return True if check(s) and check(s[:(N-1)//2]) and check(s[(N+3)//2-1:]): print('Yes') else: print('No')
p03127
s862387414
Accepted
N = int(input()) A = list(map(int,input().split())) A.sort() ans = A[N-1] update = True while update == True: update = False n = len(A) for i in range(1,n): A[i] %= A[0] C = [] for a in A: if 1 <= a: C.append(a) C.sort() A = C if A[0] < ans: ans = A[0] update = True print(ans)
p02631
s214150694
Wrong Answer
n=int(input()) a=list(map(int,input().split())) p=0 for x in a: p^=x ans=[] for x in a: ans.append(p^x) print(ans)
p02546
s009957154
Wrong Answer
w = input() if w[-1] =='s': result = w[:-1] + 'es' else: result = w + 's' print(result)
p02608
s680455232
Accepted
def main(): ans = [0] *100000 for i in range(1, 101): for j in range(1, 101): for k in range(1, 101): ans[i**2 + j**2 + k**2 + i*j + j*k + k*i-1] +=1 n = int(input()) for i in range(n): print(ans[i]) if __name__ == "__main__": main()
p03087
s821394377
Accepted
n, q = map(int, input().split()) s = str(input()) count = [0] * n for i in range(n - 1): if s[i:i+2] == "AC": count[i+1] = count[i] + 1 else: count[i+1] = count[i] for i in range(q): l, r = map(int, input().split()) l -= 1 r -= 1 print(count[r] - count[l])
p02711
s788788207
Accepted
N = input() if N.count('7') == 0: print('No') else: print('Yes')
p02659
s708922139
Accepted
def main(): A, B = input().split() A = int(A) B = float(B) B = int(B*100 + 0.5) result = str(A*B)[:-2] or '0' print(result) if __name__ == '__main__': main()
p02880
s887698315
Accepted
N = int(input()) s=0 for i in range(9): for j in range(9): if N == (i+1)*(j+1): s=1 break if s==1:break if s==1: print("Yes") else: print("No")
p03327
s286374404
Accepted
n = int(input()) print("ABC" if n<1000 else "ABD")
p03219
s565676207
Wrong Answer
X,Y = map(int, input().split()) print(X +(Y/2))
p03627
s358570154
Wrong Answer
# https://atcoder.jp/contests/arc081/tasks/arc081_a N = int(input()) A = list(map(int, input().split())) # まずは使える辺の長さを抽出 from collections import Counter A_cnt = Counter(A) candi = {k for k, v in A_cnt.items() if v > 1} if len(candi) < 2: print(0) exit() A_ls = sorted(candi, reverse=True) print(A_ls[0] * A_ls[1])
p02767
s248160422
Accepted
n = int(input()) x = list(map(int, input().split())) sum1 = 100*100**2 for i in range(101): sum2 = 0 for j in range(len(x)): sum2 += (x[j] - i)**2 if sum2 < sum1: sum1 = sum2 print(sum1)
p03730
s974526071
Accepted
a, b, c = map(int, input().split()) for i in range(1, 101): if a * i % b == c: print("YES") exit() else: print("NO")
p03486
s424628951
Accepted
s = ''.join(sorted(input(), reverse=False)) t = ''.join(sorted(input(), reverse=True)) if s < t: print('Yes') else: print('No')
p02917
s898715786
Accepted
N = int(input()) B = [float("inf")] + [int(i) for i in input().split()] + [float("inf")] A = 0 for i in range(N): A += min(B[i], B[i+1]) print(A)
p02862
s077065362
Wrong Answer
x, y = map(int, input().split()) mod = 10 ** 9 + 7 def choose(n, r): cx = 1 cy = 1 for i in range(r): cx = cx * (n - i) % mod cy = cy * (i + 1) % mod cy = pow(cy, mod - 2, mod) return cx * cy % mod if (x + y) % 3 != 0 or x < 0 or y < 0: print(0) exit() else: n = (x + y) // 3 x -= n y -= n print(choose(x + y, x))
p02779
s905851106
Wrong Answer
import sys n=int(input()) x=list(map(int,input().split())) c=[] for i in x: if i not in c: c.append(i) else: print('No') sys.exit() print('Yes')
p02797
s147969809
Accepted
import sys def input(): return sys.stdin.readline().strip() sys.setrecursionlimit(10 ** 9) def main(): N, K, S = map(int, input().split()) A = [S for _ in range(K)] if S != 10 ** 9: B = [S + 1 for _ in range(N - K)] else: B = [S - 1 for _ in range(N - K)] C = A + B print(*C, sep=" ") if __name__ == "__main__": main()
p02630
s966348488
Accepted
N = int(input()) A = list(map(int,input().split())) Q = int(input()) cnt = [0]*(10**5+1) sumA = sum(A) for a in A: cnt[a] += 1 for query in range(Q): b,c = map(int,input().split()) sumA += cnt[b]*(c-b) cnt[c] += cnt[b] cnt[b] = 0 print(sumA)
p03000
s689923587
Wrong Answer
n, x = map(int, input().split()) list = list(map(int, input().split())) jump = 0 cnt = 0 for i in list: if cnt < n and jump <= x: cnt += 1 jump += i else: break print(cnt)
p02771
s851980395
Accepted
A = list(map(int, input().split())) A = sorted(A) if A[0] == A[1] and A[1] != A[2]: print("Yes") elif A[0] != A[1] and A[1] == A[2]: print("Yes") else: print("No")
p02789
s509587034
Wrong Answer
N , M = map(int,input().split()) if 0<=N<=100 and 0 <= M <= N: if N==M: print("yes") else: print("no")
p03219
s896571407
Accepted
x, y = map(int, input().split()) print(x + y//2)
p02645
s410444278
Accepted
S = input() print(S[:3])
p02645
s095157381
Accepted
s = input() print(s[:3])
p04043
s749595518
Accepted
a, b, c = map(int, input().split()) if a == 5 and b == 5 and c == 7: print("YES") elif a == 5 and b == 7 and c == 5: print("YES") elif a == 7 and b == 5 and c == 5: print("YES") else: print("NO")
p02571
s635787223
Wrong Answer
from functools import reduce s, t = input(), input() ans = 10**9 for i in range(0, len(s) - len(t)): ans = min(ans, reduce(lambda x, a: x + (1 if a[0] != a[1] else 0), zip(s[i:], t), 0)) print(ans)
p03419
s540576285
Accepted
N,M=list(map(int, input().split())) if N>1 and M>1: print((N-2)*(M-2)) elif N*M>1: print(N*M-2) else: print(1)
p03481
s109706525
Wrong Answer
# row = [int(x) for x in input().rstrip().split(" ")] # n = int(input().rstrip()) # s = input().rstrip() # row = [int(input().rstrip()) for _ in range(n)] def resolve(): import sys input = sys.stdin.readline x, y = [int(x) for x in input().rstrip().split(" ")] # 何倍までできるか m = y / x # 2 ** ? count = 0 num = 1 while m >= num: count += 1 num *= 2 print(count) if __name__ == "__main__": resolve()
p03986
s617270667
Accepted
x = input() ans = 0 stock = 0 for i in range(len(x)): if x[i] == 'S': stock += 1 elif stock > 0: stock -= 1 else: ans += 1 print(ans+stock)
p03286
s151524576
Wrong Answer
n=int(input()) print(n%2) ans=[] while n!=0: r=n%2 ans.append(r) n=int((n-r)/(-2)) ans.reverse() for i in ans: print(i,end='')
p02957
s874372612
Wrong Answer
a,b = map(int,input().split()) if a + b % 2 == 1: print('IMPOSSIBLE') exit() print((a+b) // 2)
p03767
s543539697
Wrong Answer
n = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) print(sum(a[n:2*n]))
p02597
s181956805
Accepted
N = int(input()) C = input() l, r = 0, N - 1 ans = 0 while l < r: if C[l] == 'R': l += 1 elif C[r] == 'W': r -= 1 else: ans += 1 l += 1 r -= 1 print(ans)
p03556
s546482585
Accepted
n=int(input()) i=1 while True: if i**2>n: ans=(i-1)**2 break i+=1 print(ans)
p02621
s251168050
Wrong Answer
import random a=random.randint(1,11) print(str(a+a*a+a*a*a))
p02820
s099739252
Accepted
N, K = map(int, input().split()) dic = {} dic['s'], dic['p'], dic['r'] = map(int, input().split()) T = input() score = [0]*N for i in range(N): if i>=K and T[i]==T[i-K] and score[i-K]>0: continue score[i] = dic[T[i]] print(sum(score))
p03623
s040825847
Accepted
x, a, b = map(int, input().split()) print("BA"[abs(a - x) < abs(b - x)])
p02584
s674253600
Accepted
X,K,D = (int(x) for x in input().split()) X=abs(X) if X>K*D: print(X-K*D) else: s=X//D X-=s*D K-=s if K%2==0: print(X) else: print(abs(X-D))
p02546
s079243753
Accepted
data = input() if data[-1] == 's': data = data + "es" else: data = data + "s" print(data)
p03087
s759317644
Wrong Answer
n,q = list(map(int, input().split())) s = input() s_ps=[0]*n a =s[0] for i in range(n): b = a a = s[i] if b+a=='AC': s_ps[i]=1 #print(s_ps) for _ in range(q): r,l=list(map(int, input().split())) #print(s_ps[r-1:l]) print(sum(s_ps[r-1:l]))
p03319
s184046403
Wrong Answer
a,b = map(int,input().split(" ")) ar = list(map(int,input().split(" "))) count = 1 a -= b if a <= b and a != 0: count += 1 elif a // (b - 1) == 0: count += a // (b - 1) else: count += a // (b - 1) + 1 print(count)
p02756
s978637204
Accepted
from collections import deque S=input() Q=int(input()) query=[list(map(str,input().split())) for _ in range(Q)] ans=deque(S) reverse=False for i,q in enumerate(query): if len(q)==1: reverse=not reverse else: _,f,c=q if (f=='2') ^ reverse: ans.append(c) else: ans.appendleft(c) if reverse: print(*reversed(ans),sep='') else: print(*ans,sep='')
p02973
s012653069
Wrong Answer
n=int(input()) color_list=[[] for _ in range(n+1)] color_list[1].append(int(input())) max_color=1 for i in range(n-1): a=int(input()) max_index=0 max_number=0 for j in range(1,max_color+1): if color_list[j][-1]<a: if color_list[j][-1]>max_index: max_index=j max_number=color_list[j][-1] if max_index==0: max_color+=1 color_list[max_color].append(a) else: color_list[max_index].append(max_number) print(max_color)
p03637
s917530609
Accepted
n = int(input()) a = list(map(int, input().split())) o = 0 t = 0 f = 0 for i in range(n): if a[i]%4 == 0: f += 1 elif a[i]%2 == 0: t += 1 else: o += 1 if t == 0: if f+1 >= o: print("Yes") else: print("No") else: if f >= o: print("Yes") else: print("No")
p02959
s025744873
Accepted
n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = 0 for i in range(n): if b[i] < a[i]: c += b[i] else: d = min(a[i+1],b[i]-a[i]) a[i+1] -= d c += a[i] + d print(c)
p03862
s179864682
Accepted
import sys input = sys.stdin.readline n, x= map(int, input().split()) a_list = list(map(int, input().split())) count = 0 if a_list[0] > x: count += a_list[0] - x a_list[0] -= a_list[0] - x for i in range(len(a_list)): if i+1 == len(a_list): break if a_list[i] + a_list[i+1] > x: count += a_list[i] + a_list[i+1] - x a_list[i+1] -= a_list[i] + a_list[i+1] - x print(count)
p04033
s271014500
Wrong Answer
a, b = map(int, input().split()) zero = (a == 0 | b == 0) | (a < 0 and 0 < b) | (b < 0 and 0 < a) negative_a = (a < 0 and 0 < b) and (a + b) % 2 == 0 negative_b = (a < 0 | b < 0) if zero: print("Zero") elif negative_a | negative_b: print("Negative") else: print("Positive")
p03076
s167219810
Accepted
import math fp = 10 ans = 0 for i in range(5): a = int(input()) ans+= math.ceil(a/10)*10 if a%10!=0: fp = min(fp, a%10) print(ans+fp -10 if fp!=10 else ans )
p03338
s104195248
Accepted
n = int(input()) s = input() sn = len(set(s)) r = 0 for i in range(n+1): t = len(set(s[:i])) + len(set(s[i:])) - sn r = r if r>t else t print(r)
p02797
s047684308
Accepted
N,K,S=map(int,input().split()) A=[] for i in range(K): print(S,end=" ") for j in range(N-K): if S!=10**9: print(10**9,end=" ") else: print(1,end=" ")
p03162
s343039517
Accepted
N = int(input()) act = [] for _ in range(N): act.append(tuple(map(int, input().split()))) dp = [[0]*3 for _ in range(N)] for i in range(3): dp[0][i] = act[0][i] for i in range(1, N): for j in range(3): dp[i][j] = max(dp[i-1][(j+1) % 3], dp[i-1][(j+2) % 3]) + act[i][j] print(max(dp[N-1]))
p02777
s528655674
Accepted
s,t=map(str,input().split()) a,b=map(int,input().split()) u=input() if u==s: a-=1 elif u==t: b-=1 print("{0} {1}".format(a,b))
p02676
s122827235
Accepted
k = int(input()) s = list(str(input())) if len(s) <= k: print(''.join(s)) else: ln = s[:k] ln.append('.') ln.append('.') ln.append('.') print(''.join(ln))
p03696
s217950578
Accepted
n=int(input()) s=input() now=0 rec=0 for i in s: now+=(-1)**(i==")") rec=min(now,rec) f,t="","" if rec<0: f="("*-rec now-=rec if now>0: t=")"*now print(f+s+t)
p02787
s618294214
Wrong Answer
H, N = map(int,input().split()) data = [] for i in range(N): data.append([0, 0]) a, b = map(int,input().split()) data[i][0] = a data[i][1] = b data.sort(key=lambda x: x[0]) cost = [float("inf")] * (H + data[-1][0]) cost[0] = 0 for i in range(1, H + data[-1][0]): for magic in data: if i < magic[0]: break if cost[i] > cost[i - magic[0]] + magic[1]: cost[i] = cost[i - magic[0]] + magic[1] print(min(cost[H:]), cost, data)
p03695
s975006090
Accepted
N = int(input()) A = list(map(int, input().split())) B = [] C = 0 for i in range(N): if A[i]//400 < 8: B.append(A[i]//400) else: C += 1 b = set(B) if len(b) == 0: print(1, C) else: print(len(b), len(b)+C)
p02970
s426056485
Accepted
import math N, D = map(int,input().split()) print(math.ceil(N/(2*D+1)))
p02756
s535328263
Wrong Answer
from collections import deque S = deque(input()) Q = int(input()) sousa = [] for i in range(Q): sousa.append(input().split()) for j in range(Q): rev = 0 if sousa[j][0] == '1': rev += 1 else: if rev%2 == 1: S.reverse() if sousa[j][1] == '1': S.appendleft(sousa[j][2]) else: S.append(sousa[j][2]) Ans = ''.join(list(S)) print(Ans)
p03625
s743352835
Wrong Answer
n = int(input()) a = list(map(int, input().split())) b = sorted(set(a), reverse=True) c = [] for i in b: if a.count(i) >= 4: print(i*i) exit(0) elif a.count(i) >= 2: c.append(i) if len(c)==2: print(c[0]*c[1]) exit(0) print(0)
p03779
s053411917
Accepted
import itertools x = int(input()) itr = list(itertools.accumulate([i for i in range(100000)])) for i in range(100000): if itr[i] < x <= itr[i + 1]: print(i + 1) exit()
p03206
s633083910
Accepted
d=int(input()) if d==25: print("Christmas") elif d==24: print("Christmas Eve") elif d==23: print("Christmas Eve Eve") else: print("Christmas Eve Eve Eve")
p02612
s932331581
Accepted
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines from math import ceil #import numpy as np def main(): n = int(input()) r = ceil(n / 1000) * 1000 - n print(r) if __name__ == '__main__': main()
p03699
s255357902
Accepted
n = int(input()) s = list(int(input()) for _ in range(n)) ans = sum(s) flag = float('inf') for i in range(n): if s[i] % 10 != 0: flag = min(flag,s[i]) if ans % 10 == 0: if flag != float('inf'): print(ans - flag) else: print(0) else: print(ans)
p02881
s779355544
Wrong Answer
import math n = int(input()) n_list = [] for i in range(1, int(math.sqrt(n))): if n % i == 0: n_list.append((i, n//i)) sa = n-1 for x, y in n_list: if sa >= abs(x-1)+abs(y-1): sa = abs(x-1) + abs(y-1) print(sa)
p02675
s784563382
Accepted
N = str(input()) if N[len(N)-1] == "3" : print("bon") if N[len(N)-1] == "0" or N[len(N)-1] =="1" or N[len(N)-1] =="6" or N[len(N)-1] == "8": print("pon") elif N[len(N)-1]== "2" or N[len(N)-1] == "4" or N[len(N)-1] =="5" or N[len(N)-1] =="7" or N[len(N)-1] =="9": print("hon")
p02922
s428025300
Accepted
a,b = map(int,input().split()) consent = 1 ans = 0 while consent < b: consent += (a - 1) ans += 1 print(ans)
p03760
s826483211
Accepted
o = input() e = input() ans = '' for i in range(len(e)): ans += o[i] ans += e[i] if len(o) == len(e): pass else: ans += o[len(o)-1] print(ans)
p03998
s156896116
Accepted
sa = list(str(input())) sb = list(str(input())) sc = list(str(input())) tmp = 'a' while True: if tmp == 'a': tmp = sa.pop(0) elif tmp == 'b': tmp = sb.pop(0) elif tmp == 'c': tmp = sc.pop(0) if len(sa) == 0 and tmp == 'a': print('A') exit() elif len(sb) == 0 and tmp == 'b': print('B') exit() elif len(sc) == 0 and tmp == 'c': print('C') exit()
p02718
s685528244
Wrong Answer
N,M=(int(x) for x in input().split()) A = list(map(int, input().split())) list.sort(A,reverse = True) s=float(sum(A)/(4*M)) check=0 for i in range(0, M): if A[i]<=s: check=1 if check ==1: print('No') else: print('Yes')
p03012
s840881067
Accepted
# B n = int(input()) w = list(map(int, input().split())) l = [] for i in range(n): ans = abs(sum(w[:i]) - sum(w[i:])) l.append(ans) print(min(l))
p02556
s336020833
Accepted
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n = int(input()) xy = [tuple(map(int, input().split())) for _ in range(n)] l = [(item[0]+item[1], item[0]-item[1]) for item in xy] l.sort() v0 = l[-1][0]-l[0][0] l.sort(key=lambda x: x[1]) v1 = l[-1][1]-l[0][1] ans = max(v0,v1) print(ans)
p03069
s386339178
Accepted
N = int(input()) S = [0 if s == "#" else 1 for s in list(input())] ruisekiwa = [0]*(N+2) i = 1 r = 0 while i <= N: r = r+S[i-1] ruisekiwa[i] = r i += 1 ruisekiwa[N+1] = ruisekiwa[N] ans = 10**10 i = 1 while i <= N+1: towhite = (i-1)-(ruisekiwa[i-1]-ruisekiwa[0]) toblack = ruisekiwa[N+1]-ruisekiwa[i-1] ans = min(ans, towhite+toblack) i += 1 print(ans)