problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p04011
s747870222
Accepted
n = int(input()) k = int(input()) x = int(input()) y = int(input()) if n > k: print(k*x+(n-k)*y) else: print(n*x)
p03612
s452859871
Accepted
#!/usr/bin/env python3 import sys, math, itertools, collections, bisect input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') inf = float('inf') ;mod = 10**9+7 mans = inf ;ans = 0 ;count = 0 ;pro = 1 n=int(input()) P=list(map(int,input().split())) i=0 while i<n: if P[i]==i+1: i+=1 count+=1 i+=1 print(count)
p04043
s495644447
Accepted
a,b,c=sorted(map(int,input().split())) print(["NO","YES"][a==b==5 and c==7])
p03639
s349001289
Accepted
n=int(input()) a=list(map(int,input().split())) cnt1=0 cnt2=0 cnt4=0 for i in a: if i%2==1: cnt1+=1 elif i%4==0: cnt4+=1 elif i%2==0: cnt2+=1 if cnt2!=0: if cnt4>=cnt1: print('Yes') else: print('No') else: if cnt4+1>=cnt1: print('Yes') else: print('No')
p02681
s544800470
Wrong Answer
s = input() t = input() if len(s) + 1 == len(t) and s in t: print("YES") else: print("NO")
p02647
s383696422
Wrong Answer
import sys input=sys.stdin.readline n,k=map(int,input().split()) a=list(map(int,input().split())) for i in range(500): ans=[0]*(n) for j in range(n): l=max(0,j-a[j]) r=j+1+a[j] ans[l]+=1 if r<n: ans[r]-=1 for z in range(n-1): ans[z+1]+=ans[z] a=ans print(" ".join(list(map(str,ans))))
p03386
s062797156
Accepted
a, b, c = map(int, input().split()) if c <= (b - a + 1) // 2: for i in range(a, a+c): print(i) for i in range(b-c+1, b+1): print(i) else: for i in range(a, b+1): print(i)
p03087
s477569381
Accepted
def ss(): N,Q = list(map(int,input().split())) s = input() lis=[0]*N count = 0 for i in range(1,len(s)): if s[i-1] == 'A' and s[i] == 'C': count +=1 lis[i]+=count for i in range(Q): l,r = list(map(int,input().split())) print(lis[r-1]-lis[l-1]) ss()
p03408
s342989422
Wrong Answer
N = int(input()) S = {} for i in range(N): s = input() if s not in S: S[s] = 1 continue S[s] +=1 M = int(input()) T = {} for i in range(M): t = input() if t not in T: T[t] = 1 continue T[t] += 1 ans = 0 for key in S.keys(): if key not in T: continue ans = max(ans, S[key] - T[key]) print(ans)
p02897
s973324606
Accepted
n = int(input()) print(n // 2 / n if n % 2 == 0 else (n // 2 + 1) / n)
p02971
s065574633
Accepted
N = int(input()) max1 = [0,[]] max2 = 0 for i in range(N): a = int(input()) if a > max1[0]: max2 = max1[0] max1[0] = a max1[1] = [i] elif a == max1[0]: max1[1].append(i) elif a > max2: max2 = a if len(max1[1]) == 1: max1_idx = max1[1][0] for i in range(0,max1_idx): print(max1[0]) print(max2) for i in range(max1_idx + 1 , N): print(max1[0]) else: for i in range(N): print(max1[0])
p02819
s266269484
Wrong Answer
def is_prime(q): q = abs(q) if q == 2: return True if q < 2 or q&1 == 0: return False return pow(2, q-1, q) == 1 x=int(input()) while True: if is_prime(x)==True: break x+=1 print(x)
p03910
s986580302
Wrong Answer
import sys N = int(input()) ans = [] if N == 1: print(1) sys.exit() for i in range(1, N): n = N - i if n != 0 and n <= i: continue N = n ans.append(i) if n == 0: break print(*ans, sep='\n')
p02791
s337199313
Accepted
n = int(input()) p = list(map(int, input().split())) # 初期化 cnt = 1 min = p[0] # カウント処理 for i in range(1, n): if(p[i] <= min): cnt += 1 min = p[i] print(cnt)
p02718
s826483155
Accepted
#!/usr/bin/python3 # -*- coding: utf-8 -*- n, m = map(int, input().split()) a_list = list(map(int, input().split())) sum_a = sum(a_list) count = 0 for a in a_list: if a < sum_a / (4 * m): continue else: count += 1 if count >= m: print("Yes") else: print("No")
p03644
s770208393
Wrong Answer
n=int(input()) a=0 if n<=2: print(n) elif n<4: print(2) else: for i in range(n//2): if 2**a<=n: a+=1 else: break print(2*(a-1))
p03479
s792242129
Wrong Answer
X,Y=list(map(int, input().split())) present=[X] i=0 while present[i]<Y: present.append(present[i]*2) i=i+1 print(len(present)-1)
p02701
s027028379
Accepted
def Sol(arr): print(len(set(arr))) return #for t in range(int(input())): #n,k,d,c = map(int,input().split()) n = int(input()) arr = [] for i in range(n): arr.append(input()) #arr = list(map(int,input().split())) #k = input() #n = int(input()) Sol(arr)
p04043
s662166692
Accepted
a=list(map(int,input().split())) if a.count(5)==2 and a.count(7)==1: print("YES") else: print("NO")
p02700
s690662511
Wrong Answer
a,b,c,d=map(int,input().split()) judg=True while(judg==True): a-=d if a<=0: judg = False break c-=b if c<=0: judg = False break if a<=0: print("No") else: print("Yes")
p03407
s747161154
Accepted
a, b, c = map(int, input().split()) if a + b >= c: print('Yes') else: print('No')
p02995
s953930232
Accepted
import fractions def lcm(a,b): return a*b//fractions.gcd(a,b) a,b,c,d=map(int,input().split()) P=[c,d,lcm(c,d)] A=[] for p in P: if a%p==0: left=a//p else: left=a//p+1 right=b//p if left<=right: A.append(right-left+1) else: A.append(0) print(b-a+1-A[0]-A[1]+A[2])
p02677
s961752029
Accepted
import math a,b,h,m = map(int,input().split()) hr = h*30+m/2 mr = m*6 r = abs(hr-mr) r = min(r, 360-r) ans = a**2 + b**2 - 2*a*b*math.cos(math.radians(r)) print(math.sqrt(ans))
p03745
s246833287
Wrong Answer
N = int(input()) A = list(map(int, input().split())) count = 1 skip = False for i in range(0, N-3): if not skip: before = A[i+1] - A[i] after = A[i+2] - A[i+1] if ((before > 0) - (before < 0))*((after > 0) - (after < 0)) == -1: count += 1 skip = True else: skip = False print(count)
p02582
s930934170
Accepted
s = input() w_l = s.split('S') print(max([m for m in map(len, w_l)]))
p03331
s429031248
Accepted
from sys import stdin n = int(stdin.readline().rstrip()) mi = 10**10 for i in range(1,n): a = str(i) b = str(n-i) point = 0 for i in a: point += int(i) for j in b: point += int(j) mi = min(point,mi) print(mi)
p03644
s239033572
Accepted
N=int(input()) X=1 while X<=N: X*=2 print(X//2)
p03243
s427131947
Wrong Answer
N = int(input()) x = 111 while N < x: x += 111 print(x)
p02755
s737017531
Accepted
import math a, b = map(int, input().split()) a1 = a+1 b1 = b+1 A = a/0.08 A1=a1/0.08 B = b/0.1 B1 = b1/0.1 ans1 = set(i for i in range(math.ceil(A), math.floor(A1))) ans2 = set(j for j in range(math.ceil(B), math.floor(B1))) if ans1 & ans2 == set(): print(-1) else: ans = ans1&ans2 print(min(list(ans)))
p02661
s852938127
Wrong Answer
N = int(input()) A = [0] * (N + 1) B = [0] * (N + 1) count = 0 for i in range(1, N + 1): A[i], B[i] = map(int, input().split()) if N % 2 == 1: centerA = A[(N + 1) // 2] centerB = B[(N + 1) // 2] else: centerA = (A[N // 2] + A[N // 2 + 1]) / 2 centerB = (B[N // 2] + B[N // 2 + 1]) / 2 #print(centerA, centerB) if N % 2 == 1: count = centerB - centerA + 1 else: count = int(centerB * 2) - int(centerA * 2) + 1 print(int(count))
p02785
s339033904
Wrong Answer
n,k=map(int,input().split()) h=[int(i) for i in input().split()] h.sort a=0 if n-k<=0: print(0) else: for j in range(n-k): a+=h[j] print(a)
p02996
s733319069
Accepted
N = int(input()) List = [list(map(int,input().split(" "))) for i in range(N)] List.sort(key=lambda x: x[1]) time = 0 for i in range(N): time += List[i][0] if time > List[i][1]: print("No") break else: print("Yes")
p02777
s684816539
Wrong Answer
S,T = list(map(str,input().split())) A,B = list(map(int,input().split())) U = input() if U == 'red': print(A-1,B) else: print(A,B-1)
p03998
s952851897
Wrong Answer
# -*- coding: utf-8 -*- sa = input() sb = input() sc = input() sa = list(sa) sb = list(sb) sc = list(sc) dic = {"a":sa, "b":sb, "c":sc} #print(dic) player_selected = "a" while(True): tmp = dic[player_selected][0] #print("remove: ", tmp) dic[player_selected].remove(tmp) try: player_selected = dic[player_selected][0] #print("player_selected :", player_selected) except: #エラーが起きた場合 break print(player_selected.upper())
p03860
s190405158
Accepted
# -*- coding: utf-8 -*- #---------- s = input().strip() #---------- s_list=s.split() print(s_list[0][0] + s_list[1][0] + s_list[2][0])
p03076
s971542139
Wrong Answer
tt = [int(input()) for i in range(5)] ll = [10*i for i in range(14)] ans = [] at = bt = ct = dt = et = 0 for t in tt: i = 0 while t > ll[i]: print(t, ll[i]) i+=1 ans.append(ll[i]) max = 0 dex = 0 for i in range(5): if ans[i] - tt[i] > max: dex = i max = ans[i]-tt[i] at = 0 for j in range(5): if j != dex: at += ans[j] if j == dex: at += tt[j] print(at)
p03565
s950536535
Accepted
s, t = raw_input(), raw_input() def check(a,b): if len(a) != len(b): return False for u,v in zip(a,b): if u != v and u != '?': return False return True cand = -1 for i in range(len(s)): if check(s[i:i + len(t)],t): cand = i print (s[:cand].replace('?', 'a') + t + s[cand+len(t):].replace('?','a')) if cand != -1 else 'UNRESTORABLE'
p02742
s000201045
Wrong Answer
h,w = map(int, input().split()) if (h*w %2 ==0): print(h*w/2) else: print(((h*w)/2) +1)
p03624
s211041589
Accepted
from sys import stdin, stdout s = stdin.readline().strip('\n') al = [True for i in range(26)] for i in s: al[ord(i) - 97] = False for i in range(97, 123): if al[i - 97]: stdout.write(str(chr(i)) + '\n') break else: stdout.write('None\n')
p03479
s776402636
Wrong Answer
x, y = (int(x) for x in input().split()) from numpy import log2 ans = int(log2(y/x+1)) + 1 print(ans)
p02933
s524802752
Wrong Answer
import sys def read_string(row): return row().rstrip() def read_int(row): return int(row().rstrip()) row = sys.stdin.readline a = read_int(row) s = read_string(row) print("red" if a >= 3200 else s)
p03455
s659290424
Accepted
a,b = map(int,input().split()) if a*b%2 == 1: print("Odd") else: print("Even")
p03001
s179721957
Wrong Answer
w, h, x, y = map(int, input().split()) ans1 = w*h/2 if x % 2 != 0 or y % 2 != 0: print(ans1, 0) elif x == w//2 and y == h//2: print(ans1, 1) else: print(ans1, 0)
p02773
s933361433
Accepted
import sys from collections import defaultdict sys.setrecursionlimit(10**7) input = sys.stdin.readline n = int(input()) d = defaultdict(int) for i in range(n): s = input().rstrip() d[s] += 1 ma = 0 for v in d.values(): ma = max(ma, v) a = sorted(d.items()) for k, v in a: if ma == v: print(k)
p03495
s722971554
Wrong Answer
import collections n, k = map(int, input().split()) list = input().split() c_list = collections.Counter(list) sorted_c_list = sorted(c_list.values(),reverse=True) print(sorted_c_list[k:])
p03493
s319044169
Wrong Answer
# -*- coding: utf-8 -*- #単数値での入力,桁ごとで分解する. s = input() a = [int(c) for c in s] #出力値を設定 count = 0 # for i in range(1, 3): if a[i] == 1: count = count + 1 print(count)
p03665
s617553241
Accepted
n,p=map(int,input().split()) a=list(map(lambda x:int(x)%2,input().split())) if a.count(1)==0: print((1-p)*2**n) else: print(2**(n-1))
p03327
s189612596
Accepted
n = int(input()) print("ABC" if n <= 999 else"ABD")
p02772
s389398745
Accepted
n = int(input()) Lists=list(map(int,input().split())) x = 0 for i in Lists: if i%2==0 and i%3 !=0 and i%5!=0: print("DENIED") x = 1 break if x == 0: print("APPROVED")
p02784
s161564515
Wrong Answer
H, N = map(int, input().split()) a = list(map(int, input().split())) print(sum(a)) if H <= sum(a): print("Yes") else: print("No")
p03565
s489830308
Wrong Answer
import sys s=str(input()).replace("?", "@") t=str(input()) cnt=0 ans="" for i in range(len(s)-len(t)+1): for j in range(len(t)): if cnt==1: break; elif s[i+j]==t[j] and len(s)-i-j+1>len(t)-j: ans=s[:i]+t+s[i+len(t):] cnt+=1 if cnt>0: ans2=ans.replace("@", "a") print(ans2) else: print("UNRESTORABLE")
p03639
s976222743
Wrong Answer
N = int(input()) c1, c2, c4 = 0, 0, 0 a = list(map(int, input().split())) for i in a: if i % 4 == 0: c4 += 1 elif i % 2 == 0: c2 += 1 else: c1 += 1 result = min(c4, c1*2) * 3 + c2 // 2 print("Yes" if result >= N else "No")
p02988
s892855972
Accepted
n = int(input()) p = list(map(int, input().split())) memo = 0 for i in range(n-2): if((p[i]>p[i+1] and p[i+1]>p[i+2]) or (p[i]<p[i+1] and p[i+1]<p[i+2])): memo+=1 print(memo)
p02843
s104290446
Accepted
X=int(input()) if X>=2000: print(1) elif X//100*100<=X<=X//100*105: print(1) else: print(0)
p03329
s268192143
Accepted
# thought greedy was better i am noob def main(): n = int(input()) dp = [0 for i in range(n+4)] dp[0]=0 for i in range(1, n+2): p = 1 dp[i]=1000000000000000 while i>=p: dp[i]=min(dp[i] , dp[i-p]+1) p =p*9 p=1 while i>=p: dp[i]=min(dp[i] , dp[i-p]+1) p = p*6 print(dp[n]) if __name__=="__main__": main()
p02622
s511845983
Accepted
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify from itertools import permutations, accumulate, combinations, combinations_with_replacement from math import sqrt, ceil, floor, factorial from bisect import bisect_left, bisect_right, insort_left, insort_right from copy import deepcopy from operator import itemgetter from functools import reduce, lru_cache # @lru_cache(None) from fractions import gcd import sys # def input(): return sys.stdin.readline().rstrip() # sys.setrecursionlimit(10**6) s = input() t = input() ans = 0 for i in range(len(s)): if s[i] != t[i]: ans += 1 print(ans)
p03673
s554828470
Wrong Answer
from collections import deque n = int(input()) a = list(map(str,input().split())) d = deque() for i in range(len(a)): if i%2==0: d.append(a[i]) else: d.appendleft(a[i]) for i in range(len(d)): print(d[i]+" ",end="")
p03017
s449522315
Wrong Answer
N, A, B, C, D = map(int, input().split()) S = input() if C < D: if '##' not in S[A:D - 1]: print('Yes') else: print('No') else: if '...' in S[B - 2:D] and '##' not in S[A:C - 1]: print('Yes') else: print('No')
p02948
s608908509
Accepted
import heapq n, m = map(int, input().split()) memo = [[] for _ in range(m+1)] for _ in range(n): a, b = map(int ,input().split()) if a <= m: memo[a].append(-b) ans = 0 HQ = [] heapq.heapify(HQ) for i in range(1, m+1): for j in memo[i]: heapq.heappush(HQ, j) if HQ: ans += heapq.heappop(HQ) print(-ans)
p03673
s696763171
Wrong Answer
from collections import deque n = int(input()) a = deque(map(int, input().split())) b = deque() for i in range(n): if i % 2 == 0: b.append(a.popleft()) else: b.appendleft(a.popleft()) print(*b)
p02797
s474674529
Accepted
N, K, S = map(int,input().split()) A = [S] * K if N > K: if S < 10 ** 9: A.extend([S + 1] * (N - K)) else: A.extend([S - 1] * (N - K)) print(A[0], end = "") for i in range(1,N): print(" ", end = "") print(A[i], end = "")
p02989
s303534235
Wrong Answer
N = int(input()) N_List = sorted(list(map(int,input().split()))) std = int(N/2) ansstd = N_List[std] - N_List[std-1] print((0,ansstd)[ansstd > 1])
p03071
s569851195
Accepted
# ABC 124: A – Buttons a, b = [int(s) for s in input().split()] print(max(a * 2 - 1, a + b, b * 2 -1))
p02714
s589655951
Wrong Answer
N=int(input()) S=input() LEN=len(S) END='EEEEEEEEEEEEEEE' S += END R=S.count('R') G=S.count('G') B=S.count('B') cnt=0 for j in range(1, int(LEN/2)): for i in range(LEN): if S[i+j+j]=='E': break if (S[i] != S[i+j]) and (S[i+j] != S[i+j+j]) and (S[i] != S[i+j+j]): cnt+=1 print(R*G*B-cnt)
p03799
s623927552
Accepted
import sys import math inint = lambda: int(sys.stdin.readline()) inintm = lambda: map(int, sys.stdin.readline().split()) inintl = lambda: list(inintm()) instrm = lambda: map(str, sys.stdin.readline().split()) instrl = lambda: list(instrm()) n, m = inintm() ans = 0 if m - n*2 >= 0: ans += n m -= n*2 ans += m//4 print(ans) exit() else: if m % 2 == 0: print(m//2) exit() else: print((m-1)//2) exit()
p03407
s595094658
Wrong Answer
a,b,c = map(int,input().split()) if c >= a + 2 * b: print('Yes') else: print('No')
p03474
s110540976
Accepted
a,b = map(int,input().split()) n = input() if 1<=a<=5 and 1<=b<=5: if n[a]=="-": if n[0:a].isdecimal() and n[a+1:a+b+1].isdecimal(): print("Yes") exit() print("No")
p02657
s796435546
Accepted
a, b = map(int, input().split()) ans = a*b print(ans)
p02946
s675425422
Wrong Answer
k, x = map(int, input().split()) l = [x] for i in range(1, k): l.append(x - i) l.append(x + i) l.sort() print(l)
p03126
s413216758
Wrong Answer
n,m = map(int,input().split()) a = [[int(i) for i in input().split()] for _ in range(n)] k=[] ans = 0 for i in range(n): k.append(a[i][0]) for j in range(1,m+1): x = 0 for i in range(n): for w in range(1,(k[i]+1)): if a[i][w] == j: x +=1 print(a[i][w]) if x ==n: ans +=1 print(ans)
p03997
s730357193
Wrong Answer
a=int(input()) b=int(input()) h=int(input()) print((a+b)*h/2)
p03261
s798711100
Accepted
import sys N=int(input()) W=[list(input()) for i in range(N)] for i in range(N): for j in range(i+1,N): if W[i]==W[j]: print("No") sys.exit() for i in range(1,N): if W[i][0]==W[i-1][-1]: continue else: print("No") break else: print("Yes")
p03617
s206606574
Accepted
Q,H,S,D=list(map(int,input().split())) N=int(input()) ans=(N//2)*min(8*Q,4*H,2*S,D)+(N%2)*min(4*Q,2*H,S) print(ans)
p03627
s313550984
Wrong Answer
N, = map(int, input().split()) X = map(int, input().split()) from collections import defaultdict d = defaultdict(int) ccs = [] for x in X: d[x] += 1 if d[x] == 2: ccs.append(x) ccs.sort() if len(ccs) > 1: print(ccs[-1]*ccs[-2]) else: print(0)
p02641
s054164527
Accepted
X,N = map(int,input().split()) P = set(list(map(int,input().split()))) if X not in P: print(X) exit() i = 1 while 1: if X-i not in P: print(X-i) exit() if X+i not in P: print(X+i) exit() i += 1
p03720
s700040837
Accepted
N, M = map(int, input().split()) c = [0] * N for _ in range(M): a, b = map(int, input().split()) c[a - 1] += 1 c[b - 1] += 1 print(*c, sep='\n')
p02582
s745563841
Accepted
S = str(input()) a=0 if 'R'in S: a=1 if 'RR'in S: a=2 if 'RRR'in S: a=3 print(a)
p02813
s800154404
Wrong Answer
import itertools def main(): N = int(input()) PArry = list(map(int, input().split())) QArry = list(map(int, input().split())) a = 0 b = 0 comb = [i for i in range(1, N+1)] for i, iter in enumerate(itertools.permutations(comb)): listIter = list(iter) if PArry == listIter: a = i+1 if QArry == listIter: a = i+1 print(abs(a-b)) if __name__ == '__main__': main()
p03457
s354513881
Accepted
N = int(input()) t = [0] * (N+1) x = [0] * (N+1) y = [0] * (N+1) for i in range(N): t[i+1], x[i+1], y[i+1] = map(int, input().split()) f = True for i in range(N): dt = t[i+1] - t[i] dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]) if dt < dist: f = False if dist%2 != dt%2: f = False if f: print('Yes') else: print('No')
p02702
s245074797
Accepted
def solve(s, p=2019): s = s[::-1] memo = [0] * p memo[0] = 1 ans = 0 q = 0 r = 1 for c in s: q = (q + int(c)*r) % p ans += memo[q] r = 10*r % p memo[q] += 1 return ans s = input() print(solve(s))
p03221
s270179491
Accepted
from collections import defaultdict N, M = map(int,input().split()) l = [tuple(map(int,input().split())) for i in range(M)] # 3つめの要素でsort からの 2つめの要素でsort l_sorted = sorted((y,p,i) for i,(p,y) in enumerate(l)) d = defaultdict(lambda: 0) ans = [None] * M for a,b,c in l_sorted: d[b] += 1 ans[c] = str(b).zfill(6) + str(d[b]).zfill(6) print(*ans, sep='\n')
p03456
s292597996
Accepted
a,b=input().split() ab=int(a+b) rootab=ab**(1/2)//1 if(ab==rootab**2): print("Yes") else: print("No")
p02572
s034449639
Wrong Answer
N = int(input()) A = list(map(int ,input().split())) MOD = 1e9+7 sum = 0 for i in range (N): sum += A[i] ans = 0 for i in range(N): sum -= A[i] ans += (A[i] * sum) % MOD ans = ans % MOD print(ans)
p03557
s259712149
Accepted
import bisect N = int(input()) A = list(map(int, input().split())) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) check = [0] * N ans = 0 for i in range(N): check[i] = N - bisect.bisect_right(C,B[i]) for i in range(1,N): check[N-1-i] += check[N-i] for i in range(N): b = bisect.bisect_right(B,A[i]) if b == N: continue ans += check[b] print(ans)
p02708
s238411399
Accepted
n,k = map(int,input().split()) ans = 0 mod = 10**9 + 7 for i in range(k,n+2): ans += i*(2*n - i + 1)//2 + 1 ans %= mod ans -= i*(i-1)//2 ans %= mod print(ans)
p02923
s767062086
Accepted
N = int(input()) H = list(map(int, input().split())) cnt = 0 ans = 0 for i in range(N-1): if(H[i] >= H[i+1]): cnt += 1 else: cnt = 0 ans = max(ans, cnt) print(ans)
p02785
s815900540
Accepted
n,k=map(int,input().split()) h=sorted(list(map(int, input().split()))) res=0 if k>=n:res=0 else: res+=sum(h[:n-k]) print(res)
p03803
s532356371
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("Alice") elif a < b: print("Bob")
p02917
s444604482
Accepted
N = int(input()) B = list(map(int, input().split())) A = [] for i in range(len(B)): if i == 0: A.append(B[i]) else: if B[i-1] < B[i]: A.append(B[i-1]) else: A.append(B[i]) A.append(B[i]) ANS = 0 for i in range(len(A)): ANS = ANS + A[i] print(ANS)
p02578
s898736544
Accepted
n=int(input()) a=list(map(int,input().split())) ans=0 max=a[0] for i in range(1,n): if max>a[i]: ans+=max-a[i] else: max=a[i] print(ans)
p03696
s978536688
Accepted
N = int(input()) S = input() diff = [0] * (N + 1) for i in range(N): if S[i] == "(": diff[i + 1] = diff[i] + 1 else: diff[i + 1] = diff[i] - 1 min_diff = min(diff) print("(" * -min_diff + S + ")" * (diff[N] - min_diff))
p02665
s114334857
Wrong Answer
N = int(input()) A_leaf = list(map(int, input().split())) if N == 0: print(1 if A_leaf[0] == 1 else -1) exit() s = [0]*(N+2) for i in range(1, N+2): s[i] = s[i-1] + A_leaf[i-1] node = [1]*(N+1) for i in range(1, N+1): node[i] = min((node[i-1] - A_leaf[i-1])*2, s[N+1]-s[i]) if node[i] <= 0: print(-1) exit() else: print(sum(node))
p02556
s821045281
Accepted
n = int(input()) X = [] Y = [] for i in range(n): x,y = map(int,input().split()) X.append(x+y) Y.append(x-y) print(max(max(X)-min(X),max(Y)-min(Y)))
p03645
s562686534
Accepted
import collections N,M = map(int,input().split()) a = [list(map(int,input().split())) for _ in range(M)] a.sort() B = collections.Counter(x[0] for x in a)[1] C = set([]) for i in range(B): C.add(a[i][1]) for i in range(M): if a[i][0] in C and a[i][1] == N: print("POSSIBLE") exit() print("IMPOSSIBLE")
p02848
s335013179
Wrong Answer
N = int(input()) S = input() lst = [] for i in S: x = ord(i) if x + N > 90: x = x - 90 - 1 + 65 lst.append(chr(int(x) + N)) print(lst)
p03327
s604203031
Accepted
N=int(input()) if(N<1000): print("ABC") else: print("ABD")
p02691
s151488832
Wrong Answer
N = int(input()) A = list(map(int,input().split())) ans = 0 l = [0]*(3*10**5+10) for i in range(1,N): x = i-A[i] if x<0: continue else: l[x]+=1 if A[0]<=2*10**5: ans+=l[A[0]] for i in range(1,N): x = i+A[i] if x<0: continue if x>2*10**5: continue l[i-A[i]]-=1 ans+=l[x] print(ans)
p03720
s593471993
Accepted
N,M=map(int, input().split()) l = [] for i in range(M): a,b=map(int, input().split()) l.append(a) l.append(b) for i in range(N): print(len([1 for x in l if x==i+1]))
p03592
s354622057
Accepted
# CODE FESTIVAL 2017 予選 A: B – fLIP N, M, K = [int(s) for s in input().split()] canDo = 'No' for n in range(0, N + 1): for m in range(0, M + 1): if n * (M - m) + m * (N - n) == K: canDo = 'Yes' break print(canDo)
p03219
s558095416
Wrong Answer
X,Y=map(int,input().split()) print(X+Y/2)