problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02720
s559235833
Accepted
k = int(input()) dp = [[] for i in range(1000)] dp[0] = list(range(1,10)) D = [-1,0,1] count = 0 for i in range(10**5): count = len(dp[i]) if count > k: ans = dp[i] ans.sort() print(ans[k-1]) exit() else: k -= count for j in dp[i]: str_j = str(j) for d in D: nxt = int(str_j[-1])+d if 0<=nxt<=9: dp[i+1].append(j * 10 + nxt)
p04045
s605742183
Wrong Answer
nk=list(map(int,input().split())) d=list(map(int,input().split())) i=nk[0] ans=0 while ans==0: flag=0 for j in range(len(str(i))): if str(i)[j] in d: flag=1 break if flag==0: ans=i i+=1 print(ans)
p02708
s247490260
Accepted
n,k = map(int,input().split()) c = 0 for i in range(k,n+2): c += i*(n-i+1)+1 c = c%(10**9+7) print(c)
p02963
s172483744
Accepted
s = int(input()) x1, x2, x3 = 0, 10 ** 9, 1 a = -(-s // (10 ** 9)) b = a * (10 ** 9) - s y1, y2, y3 = 0, b, a print(x1, y1, x2, y2, x3, y3) #print(abs((x2-x1)*(y3-y1) - (x3-x1)*(y2-y1)))
p02922
s662937905
Accepted
import math a,b=map(int,input().split()) print(math.ceil((b-1)/(a-1)))
p02642
s933059966
Accepted
n = int(input()) a = list(map(int, input().split())) M = max(a) ok = [0]*(M+1) a.sort() for i in range(n): ok[a[i]] += 1 if ok[a[i]] == 1: for g in range(a[i], M+1, a[i]): if g != a[i]: ok[g] += 2 print(ok.count(1))
p03011
s810186514
Accepted
p,q,r=map(int,input().split()) print(p+q+r-max([p,q,r]))
p04034
s924164832
Accepted
n, m = map(int, input().split()) r = [False] * n r[0] = True l = [1] * n for _ in range(m): x, y = map(int, input().split()) l[x - 1] -= 1 l[y - 1] += 1 #if r[x - 1]: # r[y - 1] = True r[y - 1] = r[x - 1] | r[y - 1] if l[x - 1] == 0: r[x - 1] = False c = 0 for i in range(n): if r[i] == True and l[i] > 0: c += 1 print(c)
p03457
s824066711
Accepted
n = int(input()) curt, curx, cury = 0, 0, 0 ans = 'Yes' for _ in range(n): t, x, y = map(int, input().split()) d = abs(x - curx) + abs(y - cury) if d > (t - curt) or (t - curt) % 2 != d % 2: ans = 'No' break curt, curx, cury = t, x, y print(ans)
p03220
s775030132
Accepted
N=int(input()) T,A=map(int,input().split()) mylist=list(map(int,input().split())) mymin=10**6 index=0 for i in range(N): if(mymin>abs(A-(T-0.006*mylist[i]))): mymin=abs(A-(T-0.006*mylist[i])) index=i print(index+1)
p03719
s881331375
Wrong Answer
a, b, c = input().split() if a <= c <= b: print('Yes') else: print('No')
p04012
s151903619
Wrong Answer
#!/use/bin/env python3 from collections import defaultdict a = input() b = defaultdict(int) for c in a: b[c] += 1 d = [] for c in b.values(): d.append(c % 2) e = set(d) ans = 'Yes' if 1 in e else 'No' print(ans)
p03416
s453731881
Accepted
A,B = map(int,input().split()) cnt = 0 for i in range(A,B+1): str_i = str(i) if(str_i[0]==str_i[4] and str_i[1]==str_i[3]): cnt+=1 print(cnt)
p03761
s270283064
Accepted
n = int(input()) ans = [50]*26 al = list("abcdefghijklmnopqrstuvwxyz") for i in range(n): t = input() for s in range(26): ans[s] = min(ans[s],t.count(al[s])) for i in range(26): for t in range(ans[i]): print(al[i],end = "")
p02790
s246391504
Wrong Answer
a,b=map(int,input().split()) b=max(a,b) s=min(a,b) print(str(s)*b)
p02700
s482486957
Accepted
A,B,C,D = (int(x) for x in input().split()) while(C > 0 and A > 0 ): C -= B if(C <= 0): print("Yes") break A -= D if(A <= 0): print("No") break
p02696
s995442197
Wrong Answer
a,b,n=map(int,input().split()) print((a*(n-1)/b)-(a*int((n-1)/b)))
p02702
s199152790
Wrong Answer
# -*- coding: utf-8 -*- S = input() N = len(S) counter = 0 surplus = [0]*2019 surplus[0] += 1 for i in range(N): surplus[int(S[i:]) % 2019] += 1 print(sum([i* i-1 in surplus]))
p02811
s690232247
Accepted
k, x = [int(v) for v in input().split()] if 500 * k >= x: print("Yes"); else: print("No");
p03012
s828278342
Accepted
n=int(input()) w=list(int(i) for i in input().split()) a=max(w) for i in range(len(w)-1): tmp=abs(sum(w[:i+1])-sum(w[i+1:])) if a > tmp: a=tmp print(a)
p04044
s612301160
Accepted
n,l = map(int, input().split()) sss = [] for _ in range(n): sss.append(input()) sss.sort() print("".join(sss))
p02918
s967700549
Wrong Answer
n,k=map(int,input().split()) S=input()+'X' c=0 d=0 for i in range(n): if S[i]==S[i+1]: c+=1 if S[i]!=S[i+1]: d+=1 print(c+2*k if d>k else c+2*k-1)
p02854
s007133181
Accepted
from itertools import accumulate n = int(input()) a = list(map(int, input().split())) a_acc = list(accumulate(a)) ans = 2020202020 for i in range(n): ans = min(abs(a_acc[-1] - a_acc[i] - a_acc[i]), ans) print(ans)
p03407
s419788779
Accepted
a, b, c = map(int, input().split()) if a+b>=c: print('Yes') else: print('No')
p02683
s473364294
Wrong Answer
import itertools import numpy as np n, m, x = map(int, input().split()) l = [list(map(int, input().split())) for _ in range(n)] l = np.array(l) ans = np.sum(l, 0)[0] # ans_s = np.sum(l, 0) count = 0 # if np.any(ans_s[1:] < x): # print(-1) # exit() for i in range(1, n + 1): for j in itertools.combinations(l, i): tot = np.sum(j, 0) if np.all(tot[1:] >= x) and tot[0] < ans: ans = tot[0] count += 1 print(int(ans) if count != 0 else -1)
p02972
s359823627
Wrong Answer
n = int(input()) a = list(map(int, input().split())) ans = [0]*n for i in reversed(range(1,n)): if sum(ans[(i-i)::i])%2 != a[i]: ans[i] += 1 if sum(ans) != a[0]: ans[0] += 1 print("".join(map(str, ans)))
p03013
s710138327
Accepted
def main(): N, M, *a = map(int, open(0).read().split()) div = 1000000007 broken = set(a) comb_list = [0] * (N + 1) comb_list[0] = 1 if 1 not in broken: comb_list[1] = 1 for i in range(2, N + 1): if i in broken: continue comb_list[i] = (comb_list[i - 1] + comb_list[i - 2]) % div print(comb_list[-1]) if __name__ == "__main__": main()
p03038
s725274647
Accepted
n,m=map(int, input().split()) A=[] a=list(map(int, input().split())) for i in range(n): A.append([a[i], 1]) l=[] for i in range(m): b,c=map(int, input().split()) l.append([c,b]) A.extend(l) A.sort() A.reverse() B=[] j=0 cnt=-1 while cnt<n: B.extend([A[j][0]]*A[j][1]) cnt=cnt+A[j][1] if cnt>=n: del B[n:] j=j+1 print(sum(B))
p02753
s233155827
Accepted
s = input() if s == 'A'*3 or s == 'B'*3: print('No') else: print('Yes')
p02823
s155603035
Accepted
n, a, b = [int(i) for i in input().split()] a,b=max(a,b),min(a,b) if (a - b) % 2 == 0: print((a - b) // 2) else: c = b + (a -1- b) // 2 d = n - a + 1 + (n - (n - a + 1) - b) // 2 print(min(c,d))
p02829
s034784285
Accepted
A = int(input()) B = int(input()) for i in range (1, 4): if i != A and i != B: print(i) break
p03241
s439194212
Accepted
n,m=map(int,input().split()) a=[] for i in range(1,int(m**.5)+1): if m%i==0: if m//i>=n:a+=[i] if i>=n:a+=[m//i] print(max(a))
p03131
s895731627
Wrong Answer
K,A,B=map(int,input().split()) bis=1 if K==1: bis=2 elif A>=B-1: bis=int(K+1) else: if int((K-(A-1)))%2==0: bis=int(A+(B-A)*(K-(A-1))/2) else: bis=int(A+(B-A)*((K-(A-1))//2)+1) print(bis)
p03076
s443666436
Accepted
import sys def input(): return sys.stdin.readline().rstrip() def main(): menu = [int(input()) for _ in range(5)] ans = 0 min_m = 10 for m in menu: ans += (m + 9) // 10 * 10 if m % 10 > 0: min_m = min(min_m, m % 10) if min_m > 0: ans += min_m - 10 print(ans) if __name__ == '__main__': main()
p02842
s807910793
Wrong Answer
N=int(input()) if ((N//1.08)+1)*1.08==N: print((N//1.08)+1) if (N//1.08)*1.08==N: print(N//1.08) else: print(":(")
p02958
s346106468
Wrong Answer
n = int(input()) p = list(map(int,input().split())) cnt = 0 for i in range(1,n): if abs(p[i-1] - p[i]) > 1: cnt += 1 print('YES' if cnt == 0 or cnt == 2 else 'NO')
p02693
s194005108
Accepted
k = int(input()) a, b = map(int, input().split(" ")) res = "NG" for i in range(a, b + 1): if i % k == 0: res = "OK" break print(res)
p02631
s765599959
Accepted
n = int(input()) m = list(map(int,input().split())) xor = 0 for i in m: xor ^= i ans = [] for j in m: ans.append(xor ^ j) print(" ".join([str(k) for k in ans]))
p02835
s429685850
Accepted
a, b, c = map(int, input().split()) if (a+b+c <=21): print('win') else: print('bust')
p03556
s525463059
Accepted
#インクルード import math #定義 #ロジック箇所 N = int(input()) ruto = math.floor(math.sqrt(N)) ruto = ruto ** 2 print(ruto)
p03760
s330950199
Wrong Answer
O = input() E = input() ans = '' if O>E: ans += O[0] O = O[1:] for o, e in zip(O,E): ans += (e + o) else: for o, e in zip(O, E): ans += (o + e) print(ans)
p04012
s944756185
Accepted
s = input() lAlp = [0 for i in range(26)] for i in range(len(s)): num = ord(s[i]) - ord('a') lAlp[num] += 1 for i in range(26): if(lAlp[i] % 2 == 1): print('No') break else: print('Yes')
p02768
s577873970
Wrong Answer
n,a,b=map(int, input().split()) def modinv(a, mod=10**9+7): return pow(a, mod-2, mod) def combination(n, r, mod=10**9+7): r = min(r, n-r) res = 1 for i in range(r): res = res * (n - i) * modinv(i+1, mod) % mod return res ret = 0 ret = 2**n + 10**9+7 + 10**9+7 +1 ret = ret - combination(n, a) ret = ret - combination(n, b) ret = ret % (10**9+7) print(ret)
p02946
s901426089
Accepted
k, x = map(int, input().split()) print(*list(range(x-k+1, x+k)))
p03106
s984135475
Wrong Answer
A,B,K = map(int,input().split()) div = [] for i in range(1,100): if A%i == 0 and B%i == 0: div.append(i) print(sorted(div)[-K])
p02784
s028259943
Accepted
h,n = map(int,input().split()) a_lst = list(map(int,input().split())) if h>sum(a_lst): print('No') else: print('Yes')
p03351
s995163149
Wrong Answer
import math, sys from bisect import bisect_left, bisect_right from collections import Counter, defaultdict, deque from copy import deepcopy from functools import lru_cache from heapq import heapify, heappop, heappush from itertools import accumulate, combinations, permutations input = sys.stdin.readline mod = 10**9 + 7 ns = lambda: input().strip() ni = lambda: int(input().strip()) nm = lambda: map(int, input().split()) nl = lambda: list(map(int, input().split())) def main(): a, b, c, d = nm() if abs(b-a) <= d or abs(c-b) <= d or abs(c-a) <= d: print('Yes') else: print('No') if __name__ == '__main__': main()
p02952
s259814419
Accepted
n = int(input()) digit_list = [] cnt = 0 for i in range(1, n+1): digit_list.append(len(str(i))) for i in digit_list: if i % 2 == 1: cnt += 1 print(cnt)
p02811
s241631924
Wrong Answer
line = input() k, x = line.split(' ') if k * 500 >= x: print('Yes') else: print('No')
p02823
s234352173
Accepted
n,a,b=map(int,input().split()) if (a-b)%2==0: print(abs(a-b)//2) else: ans0=min(a,b)+abs(a-b)//2 ans1=n-max(a,b)+1+abs(a-b)//2 print(min(ans0,ans1))
p02706
s794601511
Accepted
import sys input = sys.stdin.readline def main(): N, M = map(int, input().split()) A = list(map(int, input().split())) ans = max(-1, N - sum(A)) print(ans) if __name__ == "__main__": main()
p02659
s978077100
Accepted
# -*- coding: utf-8 -*- A = input().split() a1 = int(A[0]) a2 = int(int(A[1][0])*100 + int(A[1][2])*10 + int(A[1][3])) print(int(a1*a2)//100)
p03997
s015827324
Wrong Answer
a=int(input()) b=int(input()) h=int(input()) print((a+b)*h/2)
p02724
s801813361
Accepted
X = int(input()) ans = 0 ans += 1000 * (X // 500) X = X % 500 ans += 5 * (X // 5) print(ans)
p02596
s647669307
Wrong Answer
a=int(input()) b=0 if 7%a==0:b=b+1 if 77%a==0:b=b+1 if 777%a==0:b=b+1 if 7777%a==0:b=b+1 if 77777%a==0:b=b+1 if 777777%a==0:b=b+1 if 0==b: b=-1 print(b)
p03951
s173092229
Wrong Answer
#!/usr/bin/env python # coding: utf-8 # In[27]: N = int(input()) s = str(input()) t = str(input()) # In[29]: for i in range(len(s)): # print(i, s[i:], t[:len(t)-i]) if s[i:] == t[:len(t)-i]: print(s[:i]+t) break elif i == len(s)-1: print(s+t) # In[ ]:
p02820
s672048000
Accepted
# -*- coding: utf-8 -*- """ Created on Sun Jun 14 17:18:33 2020 @author: NEC-PCuser """ N, K = map(int, input().split()) R, S, P = map(int, input().split()) T = input() score = 0 your_hand = [-1] * N # グー 0 チョキ 1 パー 2 score_dict = {"r":P, "s":R, "p":S} for i in range(len(T)): if T[i] != your_hand[i - K]: score += score_dict[T[i]] your_hand[i] = T[i] print(score)
p03478
s763305727
Accepted
import sys readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines read = sys.stdin.buffer.read sys.setrecursionlimit(10 ** 7) INF = float('inf') N, A, B = map(int, input().split()) ans = 0 for i in range(1, N+1): sum_ = sum(map(int, list(str(i)))) if A <= sum_ <= B: ans += i print(ans)
p03469
s255960672
Wrong Answer
# 85 A L = input() L1 = L.replace("7","8") print(L1)
p03438
s586029499
Accepted
n = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) numa = 0 numb = 0 num = sum(b)-sum(a) for i in range(n): x = b[i] - a[i] if x > 0: numa += -(-x//2) if x % 2 == 1: numb += 1 else: numb -= x if (num-numa)*2 == num-numb and num >= numa: print("Yes") else: print("No")
p02835
s981354079
Wrong Answer
S = list(map(int,input().split())) if sum(S) >= 22: print('burst') else: print('win')
p03210
s608588164
Wrong Answer
from itertools import product n = input() if int(n) < 100: print(0) ans = 0 for i in range(3,len(n)+1): s = list(product("753",repeat=i)) for combi in s: n_s = "".join(combi) if int(n_s) >= int(n): continue if ("7" in combi) and ("5" in combi) and ("3" in combi): ans += 1 print(ans)
p02792
s295407120
Accepted
N=int(input()) L=[[0]*10 for i in range(10)] for i in range(1,N+1): n=str(i) first=int(n[0]) last=int(n[-1]) L[first-1][last-1]+=1 ans=0 for i in range(1,N+1): n=str(i) first=int(n[0]) last=int(n[-1]) ans+=L[last-1][first-1] print(ans)
p02613
s649043223
Wrong Answer
n=int(input()) ac=0 wa=0 tle=0 re=0 for i in range(n): tmp = input() if tmp == "AC": ac+=1 elif tmp == "WA": wa+=1 elif tmp == "TLE": tle+=1 else: re+=1 print("AC ×",ac) print("WA ×",wa) print("TLE ×",tle) print("RE ×",re)
p03693
s067802155
Accepted
r, g, b = input().split() a = int(r + g + b) if a % 4 == 0: print('YES') else: print('NO')
p03555
s365379758
Accepted
a = input() b = input() if a == b[::-1]: print("YES") else: print("NO")
p02691
s698185696
Wrong Answer
n = int(input()) hlist = list(map(int, input().split())) alist = list(range(1, n+1)) ## TLE shlist = [] for height in hlist: if height < n - 1: shlist.append(height) ans = 0 # The absolute difference of their attendee numbers is equal to the sum of their heights. for i, h1 in enumerate(shlist): for j, h2 in enumerate(shlist[i+1:]): if h1+h2>n: continue if j+1 == h1+h2: ans += 1 print(ans)
p03486
s638857371
Wrong Answer
s = list(input()) t = list(input()) s.sort() t.sort(reverse=True) ans = 'Yes' if s == t: if len(s) <= len(t): ans = 'No' else: for sc, tc in zip(s, t): if sc == tc: continue if sc > tc: ans = 'No' else: ans = 'Yes' break print(ans)
p03274
s366787310
Accepted
n,k=map(int,input().split()) x=list(map(int,input().split())) a=[] for i in range(n-k+1): l=x[i] r=x[i+k-1] a.append(min(abs(l)+abs(r-l),abs(r)+abs(l-r))) print(min(a))
p03545
s254872925
Accepted
def resolve(): s = input() for i in range(1<<3): e = s[0] e += '+' if ((i>>0) & 1) else '-' e += s[1] e += '+' if ((i>>1) & 1) else '-' e += s[2] e += '+' if ((i>>2) & 1) else '-' e += s[3] if eval(e) == 7: e += '=7' print(e) return return if __name__ == "__main__": resolve()
p03862
s535797287
Accepted
n, x = map(int, raw_input().split()) ais = map(int, raw_input().split()) q= sum([ai - min(x,ai) for ai in ais]) ais = [min(x,ai) for ai in ais] for ii in range(1,len(ais)): if ais[ii] + ais[ii-1] > x: q += ais[ii] + ais[ii-1] - x ais[ii] -= ais[ii] + ais[ii-1] - x print q
p03030
s323706529
Wrong Answer
N = int(input()) rest_dict = {} city_list = [] for i in range(N): city, score = input().split() if city not in city_list: city_list.append(city) rest_dict[city] = [[score, i]] else: rest_dict[city].append([score, i]) city_list = sorted(city_list) for city in city_list: rest_list = rest_dict[city] rest_list = sorted(rest_list, reverse=True) for rest in rest_list: print(rest[1]+1)
p03617
s113689274
Accepted
Q, H, S, D = map(int, input().split()) N = int(input()) one = min(4*Q, 2*H, S) two = min(2*one, D) print(N//2 * two + N % 2 * one)
p02922
s164613978
Accepted
from math import ceil A, B = map(int, input().split()) ans = ceil((B - A) / (A-1)) + 1 # if B % A : # ans += 1 # elif B == A : # continue print(ans)
p02624
s060139553
Accepted
n = int(input()) ans = 0 for i in range(1, n+1): cnt = n//i ans += i*(cnt*(cnt+1)//2) print(int(ans))
p02720
s923221682
Accepted
import queue q_lunlun_num = queue.Queue() for i in range(1, 10): q_lunlun_num.put(i) K = int(input()) for _ in range(K): now_lunlun_num = q_lunlun_num.get() first_digit = now_lunlun_num % 10 if first_digit != 0: q_lunlun_num.put(now_lunlun_num*10 + first_digit - 1) q_lunlun_num.put(now_lunlun_num*10 + first_digit) if first_digit != 9: q_lunlun_num.put(now_lunlun_num*10 + first_digit +1 ) print(now_lunlun_num)
p02783
s387578001
Accepted
x = input().split() h = int(x[0]) a = int(x[1]) count = 0 while h > 0: count += 1 h = h - a print(count)
p03067
s345549946
Wrong Answer
a,b,c=map(int,input().split()) if a<=b and b<=c: print("Yes") elif c<=b and b<=a: print("Yes") else: print("No")
p02958
s596834020
Accepted
N = int(input()) p = list(map(int, input().split())) cnt = 0 for i in range(N): if p[i] != i+1: cnt += 1 if cnt == 0 or cnt == 2: print("YES") else: print("NO")
p03544
s825281766
Accepted
# import sys input=sys.stdin.readline def main(): N=int(input()) L=[0]*(N+1) L[0]=2 L[1]=1 for i in range(2,N+1): L[i]=L[i-1]+L[i-2] print(L[N]) if __name__=="__main__": main()
p03639
s261128641
Accepted
N = int(input()) A = [int(i) for i in input().split()] m2 = 0 m4 = 0 for a in A: m2 += int(a%2 == 0 and not a%4 == 0) m4 += int(a%4 == 0) if m4 >= N//2: print("Yes") elif m4*2 + m2 >= N: print("Yes") else: print("No")
p02732
s222215119
Accepted
import sys readline=sys.stdin.readline N=int(readline()) A=list(map(int,readline().split())) from collections import defaultdict dic=defaultdict(int) for i in range(len(A)): dic[A[i]]+=1 all=0 for v in dic.values(): all+=v*(v-1)//2 for i in range(len(A)): print(all-(dic[A[i]]-1))
p03633
s231039761
Accepted
import math def calc_lcm(x, y): return (x * y) // math.gcd(x, y) N,*T = map(int,open(0).read().split()) lcm = 1 for i in T: lcm = calc_lcm(lcm,i) print(lcm)
p02681
s878484694
Wrong Answer
S = str(input()) T = str(input()) if len(T) == len(S) + 1: print("Yes") else: print("No")
p04045
s490350465
Accepted
N, K = map(int, input().split()) D = list(map(str, input().split())) T = True while T: x = str(N) p = 0 for i in range(len(x)): if x[i] in D: p = 1 if p == 0: T = False else: N += 1 print(N)
p03285
s570712047
Wrong Answer
def main(): N = int(input()) i = 0 while 4*i <= N: j = 0 while (4*i + 7*j) <=N: print(4*i + 7*j) if (4*i+7*j == N): print('Yes') return j = j+1 i = i+1 print('No') return main()
p02773
s390984554
Accepted
n = int(input()) ds = {} for i in range(n): s = input() if s in ds: ds[s] += 1 else: ds[s] = 0 d_sorted = sorted(ds.items(), key=lambda x: x[0]) f_sorted = sorted(d_sorted, key=lambda x: x[1], reverse=True) i = f_sorted[0][1] for s in f_sorted: if s[1] == i: print(s[0]) else: break
p03657
s430223261
Accepted
a, b = map(int, input().split() ) if a % 3 != 0 and b % 3 != 0 and (a+b) % 3 != 0: print('Impossible') else: print('Possible')
p03779
s869855943
Accepted
x = int(input()) for i in range(1, 10 ** 5): if x <= (i * (i + 1)) // 2: print(i) break
p02606
s000677912
Accepted
L, R, d = map(int, input().split()) ans = 0 for i in range(L, R+1): if i%d == 0: ans += 1 print(ans)
p03545
s603634028
Accepted
x = input() y = x[0] + 't' + x[1] + 't' + x[2] + 't' + x[3] for i in range(8): for j in range(3): if ((i>>j) & 1) == 1: z = list(y) z[5-2*j] = '+' y = ''.join(z) else: z = list(y) z[5-2*j] = '-' y = ''.join(z) if eval(y) == 7: print(y+ '=7') break
p02832
s623660937
Accepted
n = int(input()) a = list(map(int, input().split())) res = 0 idx = 1 for v in a: if v == idx: idx += 1 else: res += 1 if idx == 1: print(-1) else: print(res)
p03545
s842901567
Wrong Answer
def dfs(i, f): if i == n - 1: return sum(list(map(int, f.split("+")))) # 式 f の末尾に "+" を追加するかしないかして次の数字を追加 return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + "+" + s[i + 1]) s = input() n = len(s) print(dfs(0, s[0]))
p02598
s165902173
Accepted
import math def check(A, x, k): cut_count = 0 for number in A: cut_count += (math.ceil(number / x)) -1 return cut_count <= k n, k = map(int,input().split()) a = list(map(int, input().split())) ans = 0 l = 0 r = 10 ** 9 while r - l > 1: x = (r + l) // 2 if check(a, x, k): r = x else: l = x print(r)
p02973
s357088743
Accepted
from bisect import bisect_left n = int(input()) a = [int(input()) for i in range(n)] dp = [-float("inf")] * (n + 1) for i in a: dp[bisect_left(dp, i) - 1] = i print(dp[::-1].index(-float("inf")))
p02973
s301790930
Accepted
from sys import stdin from bisect import bisect N = int(stdin.readline().rstrip()) A = [] for i in range(N): A.append(int(input())) dp = [] for a in A[::-1]: i = bisect(dp, a) if i < len(dp): dp[i] = a else: dp.append(a) print(len(dp))
p03131
s511141751
Accepted
K,A,B=map(int,input().split()) if A+2>=B: print(K+1) elif K<=A: print(K+1) else: K-=A-1 k=K//2 print(B*k-A*(k-1)+K%2)
p03607
s437116137
Accepted
import sys import math import itertools import collections import heapq import re import numpy as np from functools import reduce rr = lambda: sys.stdin.readline().rstrip() rs = lambda: sys.stdin.readline().split() ri = lambda: int(sys.stdin.readline()) rm = lambda: map(int, sys.stdin.readline().split()) rl = lambda: list(map(int, sys.stdin.readline().split())) inf = float('inf') mod = 10**9 + 7 n = ri() cnt = 0 for v in collections.Counter([ri() for _ in range(n)]).values(): if v&1: cnt += 1 print(cnt)
p02676
s930799115
Accepted
K = int(input()) S = str(input()) if len(S)<=K: print(S) elif len(S)>K: print(S[0:K]+"...")
p02596
s215117091
Accepted
K = int(input()) if K % 7 == 0: K //= 7 L = 9 * K ans = -1 r = 10 for i in range(L): if r % L == 1: ans = i + 1 break else: r = 10 * (r % L) print(ans)