We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
It's strange. I got the right answer for 10**6 on projecteuler, but TestCase2 won't pass.
Here is my code:
# Enter your code here. Read input from STDIN. Print output to STDOUTfrombisectimportbisect_leftT=int(input().rstrip())u_res=[]defSUM1(n):returnn*ninput_k=[]max_k=0for_inrange(0,T):k=int(input().rstrip())ifk>max_k:max_k=k;input_k.append(k)if1:rest=dict()i1=1sum1=SUM1(i1)stop=Falsewhilenotstop:ifsum1>max_k:stop=Truei2=i1+2sum2=SUM1(i2)whilesum2-sum1<=max_k:stop=Falseif1:ifsum2-sum1inrest:rest[sum2-sum1]+=1else:rest[sum2-sum1]=1i2+=2sum2=SUM1(i2)i1+=1sum1=SUM1(i1)s_res=sorted(rest.items())u_res=[]total_value=0forkey,valueins_res:ifvalue<=10:total_value+=1u_res.append((key,total_value))len_ures=len(u_res)forkininput_k:i=bisect_left(u_res,(k,10**6))r=0ifi>=len_ures:i-=1ifu_res[i][1]>k:ifi>0:i-=1r=u_res[i][1]else:r=0else:r=u_res[i][1]print("{}".format(r))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #174: Counting the number of "hollow" square laminae that can form one, two, three, ... distinct arrangements.
You are viewing a single comment's thread. Return to all comments →
It's strange. I got the right answer for 10**6 on projecteuler, but TestCase2 won't pass.
Here is my code: