백준 BAEKJOON 33884번 클리크 조절 [PYTHON/파이썬]

문제 출처 (BRONZE Ⅰ)

https://www.acmicpc.net/problem/33884

 

 

 

 

 

 

 

 

풀이

단순하게 생각을 해봤다.

첫 번째 사격의 좌표와 두 번째 사격의 좌표를

각각 오름차순으로 정렬을 하여 0번째 인덱스끼리 빼주면

A와 B를 구할 수 있다.

다만, 조건의 개수가 상당히 많으니

import sys를 사용하여 시간초과를 면하도록 하자.

 

 

 

 

 

 

 

코드

import sys
input = sys.stdin.readline

N = int(input())
first_shooting = [list(map(int, input().split())) for _ in range(N)]
second_shooting = [list(map(int, input().split())) for _ in range(N)]

first_shooting.sort(key=lambda x: (x[0], x[1]))
second_shooting.sort(key=lambda x: (x[0], x[1]))

A = second_shooting[0][0] - first_shooting[0][0]
B = second_shooting[0][1] - first_shooting[0][1]

print(A, B)