Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- react
- 프로그래머스 #정수삼각형 #동적계획법
- content script
- 디스코드 봇
- 백준
- C언어로 쉽게 풀어쓴 자료구조
- 캠스터디
- 동적계획법
- webpack
- TypeScript
- Message Passing
- Chrome Extension
- 자료구조
- X
- 백준 #7568번 #파이썬 #동적계획법
- 파이썬
- background script
- 크롬 확장자
- 크롬 익스텐션
- 2156
- 백준 7579
- nodejs
- discord.js
- popup
- 갓생
- supabase
- 공부시간측정어플
- 포도주시식
Archives
- Today
- Total
히치키치
[백준] 15686번 : 치킨배달 - Python(파이썬) 본문
# https://www.acmicpc.net/problem/15686
from itertools import combinations
N,M = map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(N)]
chick = []
house = []
dist = int(1e9)
for i in range(N):
for j in range(N):
if arr[i][j] == 1:
house.append((i,j))
elif arr[i][j] == 2:
chick.append((i,j))
for j in combinations(chick, M):
total = 0
for i in house:
tmp = int(1e9)
for k in j:
#print(k)
tmp = min(tmp, abs(k[0]-i[0])+abs(k[1]-i[1]))
#print("chick",k[0],k[1])
#print("house", i[0],i[1])
total+=tmp
dist = min(dist, total)
print(dist)
'알고리즘 스터디' 카테고리의 다른 글
[백준] 3190번 : 뱀 - Python(파이썬) (0) | 2023.09.04 |
---|---|
[백준] 1074번 : Z - Python(파이썬) (0) | 2022.06.13 |
[백준] 4179번 : 불! - Python(파이썬) (0) | 2022.06.03 |
[백준] 7579번 : 토마토 - Python(파이썬) (0) | 2022.06.02 |
[백준] 6549번 : 히스토그램에서 가장 큰 직사각형- Python(파이썬) (0) | 2021.08.24 |
Comments