problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03071
s206615752
Wrong Answer
p,q= input().split() (a,b) =(int(p), int(q)) size_bottum = [a,b] total = 0 total +=max(size_bottum) total +=max(size_bottum) -1 print(total)
p03773
s929284073
Accepted
A,B=map(int,input().split()) #print(sorted(B)[0]) print((A+B)%24)
p02613
s394490196
Accepted
f = {"AC":0, "WA":0, "TLE":0,"RE":0} for i in range(int(input())): s = input() f[s]+=1 for i in f: print(i,"x", f[i])
p03069
s438226653
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()) s = input() v1 = [None]*n v2 = [None]*n v = 0 for i in range(n): if s[i]=="#": v += 1 v1[i] = v v1.insert(0,0) v = 0 for i in range(n-1, -1, -1): if s[i]==".": v += 1 v2[i] = v v2.append(0) ans = min((v1[i]+v2[i]) for i in range(n+1)) print(ans)
p03274
s911835881
Accepted
# 初期入力 2020-0730-2150 from bisect import bisect_left import sys input = sys.stdin.readline #文字列では使わない N,K = map(int, input().split()) x = list(map(int, input().split())) x_shift =[i +abs(x[0]) for i in x] dist =[] for i in range(N-K+1): d_end =x_shift[i+K-1] -x_shift[i] #ローソクK本の内、端と端の距離 d_left =abs(x[i]) d_right =abs(x[i+K-1]) dist.append(d_end +min(d_left,d_right)) print(min(dist))
p02754
s088004505
Accepted
import sys import os def main(): if os.getenv("LOCAL"): sys.stdin = open("input.txt", "r") N, A, B = list(map(int, sys.stdin.buffer.readline().split())) n = N//(A+B) m = N%(A+B) print(A*n + min(m, A) if m > A else A*n + m) if __name__ == '__main__': main()
p03013
s406695602
Wrong Answer
import math def comb(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) n, m = (int(xi) for xi in input().split()) a = [] diff = 0 a0 = 0 a1 = 0 for xi in range(m): a0 = a1 a1 = int(input()) a.append(a1) if a1-a0>diff : diff=a1-a0 print(comb(n,diff)) print(diff) print(a) p = [1] for xi in range(1,diff+1): add = 1 for j in range(1, int(xi/2)): add += comb(xi-j,j) p.append(add)
p02627
s193559410
Accepted
a = input() if a.islower(): print("a") else: print("A")
p03456
s651857703
Accepted
from math import sqrt a, b = map(str, input().split()) if sqrt(int(a+b)) % 1 == 0: print("Yes") else: print("No")
p03380
s787693973
Wrong Answer
from math import factorial as f n=int(input()) a=list(map(int,input().split())) def comb(n,r): return int(f(n)/(f(r)*f(n-r))) m=max(a) r=0 for i in range(n): if abs(m/2-a[i])<abs(m/2-r): r=a[i] print(comb(m,r))
p02795
s876080301
Wrong Answer
H=int(input()) W=int(input()) N=int(input()) M=max(H,W) print(N//M)
p03611
s774577289
Accepted
N = int(input()) A = list(map(int,input().split())) cnt = [0]*(10**5+2) for a in A: cnt[a] += 1 ans = [] for a in A: if a == 0: ans.append(cnt[a] +cnt[a+1]) else: ans.append(cnt[a-1] + cnt[a] +cnt[a+1]) print(max(ans))
p03448
s286040194
Accepted
def coins(a,b,c,x): num=0 for i in range(a+1): for w in range(b+1): for q in range(c+1): if 500*i + 100*w + 50*q == x: num += 1 return num def main(): a=int(input()) b=int(input()) c=int(input()) x=int(input()) print(coins(a,b,c,x)) if __name__ == '__main__': main()
p03103
s998888679
Accepted
n, m = map(int, input().split()) drink = [] for i in range(n): a, b = map(int, input().split()) drink.append((a,b)) drink.sort(key=lambda x: x[0]) ans = 0 for ai in drink: ans += ai[0] * min(ai[1], m) m -= ai[1] if m <= 0: print(ans) break
p03817
s510505978
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n = int(readline()) ans = n // 11 * 2 if 1 <= n % 11 <= 6: ans += 1 elif 7 <= n % 11 <= 10: ans += 2 print(ans)
p03672
s036661595
Wrong Answer
S = input() s = len(S) if s == 2: print(1) for i in range(1,s//2): a = s - i*2 if a != 0: test = S[0:a] n = 0 while True: if n == a/2: print(len(test)) break elif test[n] != test[n + a//2]: break else: n += 1 else: print(2)
p02602
s417102131
Wrong Answer
#!/usr/bin/env python # -*- coding: utf-8 -*- def main(): N, K = map(int, input().split()) A = list(map(int, input().split())) tmp = 1 for k in A[:K]: tmp += k for i in range(N - K): if tmp < tmp / A[i] * A[i + K]: print("Yes") else: print("No") if __name__ == "__main__": main()
p03385
s058700626
Accepted
S = input() print("Yes" if len(set(S)) == 3 else "No" )
p03319
s602555195
Wrong Answer
import math N, K = map(int, input().split()) A_list = list(map(int, input().split())) pos_1 = 0 for i in range(N): if A_list[i] == 1: pos_1 = i ans = math.ceil((pos_1)/(K-1)) + math.ceil((N-1-pos_1)/(K-1)) print(ans)
p03037
s407547769
Accepted
N, M = map(int, input().split()) c_min = 1 c_max = 10 ** 5 for i in range(M): LM = list(map(int, input().split())) c_min = max(c_min, LM[0]) c_max = min(c_max, LM[1]) if c_min > c_max: print(0) else: print(c_max - c_min + 1)
p02766
s114864021
Accepted
import math N,K = map(int,input().split()) x = math.log(N,K)+0.0000000000001 print(math.ceil(x))
p02899
s607094621
Accepted
def abc142c_go_to_school(): n = int(input()) a = list(zip(range(1, n+1),list(map(int, input().split())))) a.sort(key=lambda x: x[1]) for item in a: print(item[0], end=' ') abc142c_go_to_school()
p03377
s917620303
Wrong Answer
a,b,x = map(int,input().split()) if a<x and b>x: print("YES") else: print("NO")
p03456
s044589463
Wrong Answer
import math a,b=input().split() x=int(a+b) print(x) if math.sqrt(x).is_integer ==True: print('Yes') else: print('No')
p03282
s708924115
Wrong Answer
S = list(input()) K = int(input()) ans = 1 for i in range(len(S)): if S[i] != '1' : ans = S[i] break print(ans)
p03797
s816363566
Accepted
n, m = map(int, input().split()) ans = min(n, m // 2) m -= ans * 2 ans += max(0, m // 4) print(ans)
p03773
s878176833
Accepted
n = input().split() a = int(n[0]) b = int(n[1]) c = a+b if c >= 24: c -= 24 print(c)
p03745
s130349246
Accepted
n = int(input()) A = list(map(int, input().split())) #%% flag = None up = False down = False ans = 1 base = A[0] for i in range(1, n): if base < A[i]: up = True base = A[i] elif base > A[i]: down = True if (up == True) and (down == True): up = False down = False ans += 1 base = A[i] print(ans)
p03637
s057042316
Accepted
N = int(input()) an = list(map(int, input().split())) four = 0 odd = 0 for a in an: if a % 2 == 1: odd += 1 elif a % 4 == 0: four += 1 print('Yes' if odd <= four or N//2 == four and -(-N//2) == odd else 'No')
p02731
s603161870
Accepted
L = int(input()) x = (1/3) * L ans = x**3 print(ans)
p03565
s591142236
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) s = readline().rstrip().decode() t = read().rstrip().decode() ans = [] for i in range(len(s) - len(t) + 1): for j, (ss, tt) in enumerate(zip(s[i:], t)): if ss not in ('?', tt): break else: memo = s[:i] + t + s[i + len(t):] ans.append(memo.replace('?', 'a')) print(min(ans) if ans else 'UNRESTORABLE')
p03836
s788719429
Wrong Answer
import numpy as np import fractions as fra sx,sy,ex,ey=map(int,input().split()) ex-=sx ey-=sy s="" for i in range(ey): s+="U" for i in range(ex): s+=("R") for i in range(ey): s+=("D") for i in range(ex): s+=("L") s+=("D") for i in range(ex+1): s+=("R") for i in range(ey+1): s+=("U") s+=("LD") print(s)
p03281
s387998606
Accepted
n = int(input()) cnt = 0 for i in range(105,n+1,2): cnt2 = 0 for j in range(3,i,2): if i % j == 0: cnt2 += 1 if cnt2 == 6: cnt += 1 print (cnt)
p03220
s273150739
Accepted
n = int(input()) t, a = map(int, input().split()) h = list(map(int, input().split())) l = list(map(lambda x: abs(a - (t - 0.006 * x)), h)) print(l.index(min(l))+1)
p03632
s257965018
Accepted
A, B, C, D = map(int, input().split()) result = 0 for a in range(A, B): if C <= a and a < D: result += 1 print(result)
p03338
s533396528
Accepted
n=int(input()) s=input() ans=0 for i in range(n-1): cnt=0 a=set(s[:i+1]) b=set(s[i+1:]) for j in a: if j in b: cnt+=1 if ans<cnt: ans=cnt print(ans)
p04031
s074377511
Wrong Answer
N = int(input()) a = list(map(int,input().split())) tmp = max(a)+min(a) if tmp%2==0: tmp = tmp//2 else: tmp = tmp//2+1 print(sum(map(lambda x:(x-tmp)**2,a)))
p04045
s653086857
Accepted
def solve(): N, K = map(int, input().split()) D = list(map(int, input().split())) while True: S = list(str(N)) for s in S: if int(s) in D: break else: return N N += 1 print(solve())
p02786
s961356698
Accepted
print(2**len(bin(int(input())))//4-1)
p03485
s564963012
Accepted
a,b=map(int,input().split()) print((a+b+1)//2)
p02882
s618803498
Accepted
import math # factorical(階乗) # hypot(距離) # import heapq # from fractions import gcd # Python3.5以前 # lcm(最小公倍数) = (a*b)//gcd(a,b) # from fractions import Fraction # from math import gcd # Python3.6以降 # -------------------------------------------------------------- a,b,x = map(int,input().split()) if x*2 <= a*a*b: print(math.degrees(math.atan(a*b*b/(2*x)))) else: print(math.degrees(math.atan((a*a*b-x)*2/(a**3))))
p02861
s841173534
Accepted
import itertools import math n = int(input()) lis1 = [] for i in range(n): lis1.append(list(map(int, input().split()))) S = 0 for i in list(itertools.permutations(range(n))): for j in range(n-1): S += math.sqrt((lis1[i[j]][0]-lis1[i[j+1]][0])**2 + (lis1[i[j]][1]-lis1[i[j+1]][1])**2) for i in range(1, n+1): S = S / i print(S)
p03000
s022260484
Accepted
n,x = map(int, raw_input().split(' ')) ais = map(int, raw_input().split(' ')) count,cur,i = 1,0, 0 res = [] while(i < len(ais)): cur += ais[i] if cur <= x: count+=1 else: break i +=1 print count #print len([e for e in res if e <= x])
p02612
s911243778
Accepted
N = int(input()) print(0 if N%1000 == 0 else 1000-(N%1000))
p02814
s550016840
Accepted
N, M = map(int, input().split()) A = list(set(map(lambda x : int(x)//2, input().split()))) def gcd(x, y): return x if y == 0 else gcd(y, x % y) def lcm(x, y): return (x * y) // gcd(x, y) l = A[0] for a in A[1:]: l = lcm(l, a) ans = (M // l + 1) // 2 for a in A[1:]: if (l // a) % 2 == 0: ans = 0 break print(ans)
p03495
s208671108
Accepted
from collections import Counter N, K = map(int, input().split()) A = list(map(int, input().split())) print(N - sum(x[1] for x in Counter(A).most_common(K)))
p03059
s763823464
Accepted
# coding: UTF-8 import sys import numpy as np a,b,t = map(int, input().split()) print(b * (t//a))
p02727
s106357598
Accepted
X,Y,A,B,C=map(int,input().split()) P=sorted(list(map(int,input().split()))) Q=sorted(list(map(int,input().split()))) R=sorted(list(map(int,input().split()))) print(sum(sorted(P[-X:]+Q[-Y:]+R)[-X-Y:]))
p02924
s594294308
Accepted
N = int(input()) n = N-1 ans = ((n+1)*n)//2 print(ans)
p02765
s172691702
Accepted
n, r = map(int, input().split()) ans = r + 100 * (10 - min(10, n)) print(ans)
p02786
s546596902
Wrong Answer
# coding: utf-8 # Your code here! H=int(input()) opt=[1] while opt[-1]<=10**12: opt.append(opt[-1]*2+1) count=0 temp=1 while temp<H: temp*=2 count+=1 if count>39: print(opt[-1]) else: print(opt[count])
p02603
s972554813
Accepted
N = int(input()) A = list(map(int, input().split())) mon = 1000 #所持金 cnt = 0 #株の所持数 cur = A[0] for i in range(1,len(A)): sec = A[i] #値上がりする前に購入 if cur < sec: #買えるだけ買う if mon > cur: cnt = mon//cur mon = mon%cur #値が下がる前に売却 elif cur > sec: mon += cur * cnt cnt = 0 cur = sec if cnt > 0: mon += A[-1]*cnt print(mon)
p02951
s813953991
Accepted
A, B, C = map(int,input().split()) y = C - A + B if y >= 0: print( y ) else: print( 0 )
p03416
s182965593
Wrong Answer
def is_palindrome(s: str) -> bool: return s[:len(s)//2] == s[-1*(len(s)//2):] a, b = [int(i) for i in input().split()] print([is_palindrome(str(n)) for n in range(a, b+1)].count(True))
p03711
s581252251
Accepted
a=list(map(int, input().split())) s=[[1,3,5,7,8,10,12],[4,6,9,11],[2]] ans=[] for i in a: for j in range(len(s)): if i in s[j]: ans.append(j) break if len(set(ans))==1: print('Yes') else: print('No')
p03556
s150201349
Wrong Answer
n=int(input()) for i in range(1,10**3+2): if i**2>n:print((i-1)**2)
p02720
s595288649
Wrong Answer
k = int(input()) c = 0 x = 0 sx = 0 while c < k: sx = str(x) c+=1 for i in range(len(sx)-1): if abs(int(sx[i]) - int(sx[i+1])) > 1: c-=1 break x+=1 print(x)
p03485
s263012425
Wrong Answer
a,b = map(int,input().split()) ans = (a+b)/2 #print(ans) if ans%2 == 1: print((a+b)//2+1) else: print((a+b)//2)
p03456
s681110783
Accepted
a, b = input().split() n = int(a+b) if n == int(n**(1/2))**2: print('Yes') else: print('No')
p03607
s603033272
Accepted
n = int(input()) a = [] for i in range(n): a.append(int(input())) a.sort() jud = 1 q = a[0] ans = 0 for i in range(1,n): if(q==a[i]): jud += 1 else: if(jud%2==1): ans += 1 jud = 1 q = a[i] if (jud%2==1): ans += 1 if(n==1): ans = 1 print(ans)
p03284
s172149937
Wrong Answer
n,k = map(int, input().split()) print(n%k)
p02665
s627013827
Accepted
import sys import math import itertools import collections import heapq import numpy as np rl = sys.stdin.readline n = int(rl()) li = list(map(int, rl().split())) if n == 0 and li[0] == 1: print(1) exit() can = [1-li[0]] a = can[0] for i in range(1, n+1): a = a*2 can.append(a) a -= li[i] if a < 0: print(-1) exit() ans = 0 can.reverse() li.reverse() temp = 0 for i in range(n+1): temp += li[i] ans += min(can[i], temp) print(ans)
p03407
s576678190
Accepted
a,b,c=map(int,input().split()) print("No" if a+b<c else "Yes")
p03339
s354515781
Accepted
N = int(input()) S = input() ES, WS= [0]*(N+1), [0]*(N+1) ES[0], WS[0] = 0, 0 for i in range(1, N+1): if S[i-1] == "E": ES[i] = ES[i-1] + 1 WS[i] = WS[i-1] elif S[i-1] == "W": WS[i] = WS[i-1] + 1 ES[i] = ES[i-1] ans = 10**18 for i in range(1, N+1): ans = min(ans, WS[i-1] + ES[N] - ES[i]) print(ans)
p03408
s047285982
Wrong Answer
n = int(input()) B = [input() for _ in range(n)] m = int(input()) R = [input() for _ in range(m)] L = list(set(B) | set(R)) dict = {key:0 for key in L} for b in B: dict[b] += 1 for r in R: dict[r] -=1 print(max(dict.values()))
p02639
s902498115
Wrong Answer
x = list(map(int, input().split())) print(17-sum(x))
p02924
s277450968
Wrong Answer
A = int(input()) - 1 if A ==0 :print(A) else : print(int(A*(A+1)/2))
p02639
s864009453
Accepted
x=list(map(int,input().split())) for i in range(5): if x[i]==0: print(i+1) exit()
p03417
s380153110
Accepted
n,m = map(int,input().split()) if n==1 and m==1: ans=1 elif n==1 or m==1: ans=max(n,m)-2 else: ans = (n-2)*(m-2) print(ans)
p02771
s545563936
Accepted
a = list(map(int,input().split())) if len(set(a)) == 2: print("Yes") else: print("No")
p03327
s745684322
Accepted
n = int(input()) if n<1000: print("ABC") else: print("ABD")
p03434
s954407740
Accepted
n,s = int(raw_input()),map(int,raw_input().split()) s.sort(key = lambda x:-x) print sum(s[0:n:2]) - sum(s[1:n:2])
p02633
s169537314
Accepted
x = int(input()) for i in range(1000): if x * (i+1) % 360 == 0: print(i+1) exit()
p02584
s017149646
Accepted
X, K, D = map(int, input().split()) X = abs(X) a, b = divmod(X, D) # print(f'{a=}, {b=}') if a >= K: ans = X - K * D ans = abs(ans) print(ans) exit() _K = K - a # print(f'{_K=}') if _K % 2 == 0: ans = b else: ans = abs(b - D) print(ans)
p02664
s814504943
Accepted
def solve(): T = input() ans = T.replace('?','D') return ans print(solve())
p02583
s342312987
Accepted
n = int(input()) a = list(map(int,input().split())) ans = 0 for i in range(n): for j in range(i+1,n): for k in range(j+1,n): b = [a[i],a[j],a[k]] b.sort() if b[0] == b[1] or b[1] == b[2]: pass elif b[0] + b[1] > b[2]: ans += 1 print(ans)
p03838
s398004574
Accepted
x, y = map(int, input().split()) ans = 0 Button = [(1, 1), (1, 0), (0, 1), (0, 0)] ans = float("INF") for fb, lb in Button: t, tx, ty = 0, x, y if fb: tx = -x t += 1 if lb: ty = -y t += 1 if tx > ty: continue t += ty - tx ans = min(ans, t) print(ans)
p02848
s620211517
Accepted
n = int(input()) s = input() l = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ' ans = '' for t in s: ans += l[l.index(t)+n] print(ans)
p02729
s621486985
Wrong Answer
import math N, M = list(map(int, input().split())) if N==M==1: print(1) elif M < 2: print(int(math.factorial(N)/math.factorial(2)/math.factorial(N-2))) elif N==0: print(int(math.factorial(M)/math.factorial(2)/math.factorial(M-2))) else: print(int(math.factorial(N)/math.factorial(2)/math.factorial(N-2) + math.factorial(M)/math.factorial(2)/math.factorial(M-2)))
p03105
s865005800
Accepted
a, b, c = map(int, input().split()) print(min(b // a, c))
p03779
s957711874
Accepted
n=int(input()) ans=0 while (ans*(ans+1))//2<n: ans+=1 print(ans)
p02621
s930931338
Accepted
a = int(input()) ans = a + a ** 2 + a **3 print(str(ans))
p03162
s038269036
Wrong Answer
n = int(input()) abc = [] for i in range(n): abc.append([int(i) for i in input().split()]) dp = [[0,0,0] for i in range(n)] for i in range(n): if i != 0: for j in range(3): for k in range(3): if j != k: dp[i][j] = max(dp[i][j],dp[i-1][k] + abc[i][j]) else: for j in range(3): dp[i][j] = abc[i][j] print(max(dp[n-1])) print(dp)
p03241
s932050431
Wrong Answer
N,M = map(int,input().split()) n = M // N m = 0 for i in range(1,N+1): x = i if M % x == 0: if M//x <= n: print(M//x) quit() m = x print(m)
p02766
s219763317
Wrong Answer
import numpy as np N,K = map(int,input().split()) a = True b=0 if N<K: print(1) elif K==10: while(a): if N//K==0: a=False else: N=N//K+N%K b+=1 print(b+1) else: while(a): if N//K==0: a=False else: N=N//K+N%K b+=1 print(b)
p03556
s191062029
Accepted
n = int(input()) print(int(n**.5)**2)
p02584
s311679445
Wrong Answer
import math x, k, d = map(int, input().split()) if x > d * k: print(abs(x-d*k)) else: if k % 2 == 1: print(abs(x - math.ceil(x/d) * d)) else: print(abs(x - (math.ceil(x/d) - 1) * d))
p03077
s971892860
Accepted
from math import ceil n = int(input()) a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) print(ceil(n/min(a, b, c, d, e))+4)
p03799
s158297061
Wrong Answer
N,M = map(int,input().split()) def solve(N,M): # 今あるもの if M < N * 2: return N M -= N * 2 ans = N + M // 3 return ans print(solve(N,M))
p02759
s787075675
Wrong Answer
N = int(input()) print( N//2 + 1)
p02972
s893676056
Accepted
N = int(input()) a = [0] a += list(map(int, input().split(' '))) b = [0 for _ in range(N + 10)] for i in range(N, 0, -1): res = 0 for j in range(N // i * i, i, -i): res = res ^ b[j] b[i] = res ^ a[i] print(sum(b)) for i in range(1, N + 1): if b[i]: print(i)
p02633
s902935798
Accepted
import sys import math import fractions from collections import deque from collections import defaultdict sys.setrecursionlimit(10**7) X = int(input()) def lcm(x, y): return (x * y) // math.gcd(x, y) l = lcm(360, X) print(l // X)
p02823
s545931505
Accepted
N,A,B=map(int,input().split()) if (A-B)%2==0: print((B-A)//2) exit() print(min((A+B-1)//2,(N-B+N-A+1)//2))
p03693
s260044844
Accepted
def main(): r, g, b = map(int, input().split()) num = r*100+g*10+b if num % 4 == 0: print('YES') else: print('NO') main()
p03672
s488809449
Wrong Answer
s = str(input()) s1 = "" s2 = "" flag = 0 for i in range(len(s)): if not 0 == i and not len(s) == i: if i % 2 == 0: # print("---i--- {0}".format(i)) s1 = s[0:int((len(s)-i)/2)] s2 = s[int((len(s)-i)/2):len(s)-i] # print(len(s)-i) # print("{0} --s1 \n {1} --s2".format(s1,s2)) if s1 == s2: flag = len(s)-i print(flag)
p02789
s837484142
Accepted
# coding: utf-8 # Your code here! n,m=map(int,input().split()) if n==m: print("Yes") else: print("No")
p03059
s021339559
Accepted
a, b, t = map(int, input().split()) print(int((t + 0.5) // a * b))
p03160
s793413792
Wrong Answer
def chmin(dp, i, target): if (dp[i] > target): dp[i] = target n = int(input()) h = [i for i in input().split(" ")] dp =[10**4] * n dp[0] = 0 for i in range(1, n): chmin(dp, i, dp[i - 1] + abs(int(h[i]) - int(h[i - 1]))) if i > 1: chmin(dp, i, dp[i - 2] + abs(int(h[i]) - int(h[i - 2]))) print(dp[n - 1])
p03241
s272146519
Accepted
#112_D N,M=map(int,input().split()) #M//N以下のMの約数の最大 divisors=[] for i in range(1,int(M**.5)+1): if M%i==0: divisors.append(i) if i!=(M//i): divisors.append(M//i) Ans=1 for x in sorted(divisors): if M//N>=x: Ans=x else: break print(Ans)
p02623
s056487189
Accepted
n,m,k=map(int,input().split()) A=list(map(int,input().split())) B=list(map(int,input().split())) a,b=[0],[0] for i in range(n): a.append(a[i]+A[i]) for i in range(m): b.append(b[i]+B[i]) ans=0 j=m for i in range(n+1): if a[i]>k: break time=a[i]+b[j] while time>k: j-=1 time=a[i]+b[j] ans=max(ans,i+j) print(ans)