본문 바로가기
python-algorithm

[백준] 15923

by 무적김두칠 2021. 1. 4.

1
2
3
4
5
6
7
8
9
10
import sys
n=int(sys.stdin.readline())
tmp=[]
for  i in range(n):
    a,b=map(int,sys.stdin.readline().split())
    tmp.append( (a,b) )
cnt=0
for i in range(1,n):
    cnt+= abs (tmp[i][0]-tmp[i-1][0]) + abs (tmp[i][1]-tmp[i-1][1])
print(cnt + abs (tmp[0][0]-tmp[len(tmp)-1][0]) + abs (tmp[0][1]-tmp[len(tmp)-1][1]))
cs
반응형

'python-algorithm' 카테고리의 다른 글

[백준] 15995  (0) 2021.01.04
[백준] 15953  (0) 2021.01.04
[백준] 15917  (0) 2021.01.04
[백준] 15820  (0) 2021.01.04
[백준] 15818  (0) 2021.01.04

댓글