Advertisement
giGii

best station

Apr 20th, 2022
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. def main():
  2.     n = int(input())
  3.     metro_stations = []
  4.     for i in range(n):
  5.         station = tuple(map(int, input().split()))
  6.         metro_stations.append(station)
  7.  
  8.     m = int(input())
  9.     bus_stations = {}
  10.     for j in range(m):
  11.         station = tuple(map(int, input().split()))
  12.         bus_stations[station] = bus_stations.get(station, 0) + 1
  13.  
  14.     maximum_stations_around = 0
  15.     best_metro_station = 1
  16.     station = 1
  17.     R = 20
  18.     for metro in metro_stations:
  19.         Mx, My = metro[0], metro[1]
  20.         counter = 0
  21.         for X in range(-R, R + 1):
  22.             y_range = int((R * R - X * X) ** 0.5)
  23.             for Y in range(-y_range, y_range + 1):
  24.                 counter += bus_stations.get((X + Mx, Y + My), 0)
  25.         if counter > maximum_stations_around:
  26.             maximum_stations_around = counter
  27.             best_metro_station = station
  28.         station += 1
  29.  
  30.     print(best_metro_station)
  31.  
  32.  
  33. if __name__ == '__main__':
  34.     main()
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement