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.
i managed to pass the first 4 test cases but was unable to pass further because of time limits, i definitetly took the fastest approach possible in python. There is no way python can calculate distance across 99k points in the given time limit
#!/bin/python3importmathimportosimportrandomimportreimportsysdefdist(a,b,c):returnmin(abs(a-b),c-abs(a-b))defdbp(points,n,c):distances=[]forpointinpoints:foriinrange(n):point2=points[i]distances.append(min(dist(point[0],point2[0],c),dist(point[0],point[1],c),dist(point[0],point2[1],c),dist(point2[0],point2[1],c),dist(point[1],point2[0],c),dist(point[1],point2[1],c)))returnmax(distances)if__name__=='__main__':nc=input().split()n=int(nc[0])c=int(nc[1])points=[]for_inrange(n):points.append(list(map(int,input().rstrip().split())))# Write Your Code Hereprint(dbp(points,n,c))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Distant Pairs
You are viewing a single comment's thread. Return to all comments →
i managed to pass the first 4 test cases but was unable to pass further because of time limits, i definitetly took the fastest approach possible in python. There is no way python can calculate distance across 99k points in the given time limit