From 4f8933cbfd0c6873f7a5de6f8ef75791091d80f1 Mon Sep 17 00:00:00 2001 From: kimgwon <92065911+kimgwon@users.noreply.github.com> Date: Sun, 8 Oct 2023 08:24:44 +0900 Subject: [PATCH 1/3] Create jiwon.py --- .../jiwon.py" | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 "Baekjoon - \353\254\270\354\240\234\355\222\200\354\235\264/\352\263\265\354\234\240\352\270\260 \354\204\244\354\271\230/jiwon.py" diff --git "a/Baekjoon - \353\254\270\354\240\234\355\222\200\354\235\264/\352\263\265\354\234\240\352\270\260 \354\204\244\354\271\230/jiwon.py" "b/Baekjoon - \353\254\270\354\240\234\355\222\200\354\235\264/\352\263\265\354\234\240\352\270\260 \354\204\244\354\271\230/jiwon.py" new file mode 100644 index 0000000..70d96b0 --- /dev/null +++ "b/Baekjoon - \353\254\270\354\240\234\355\222\200\354\235\264/\352\263\265\354\234\240\352\270\260 \354\204\244\354\271\230/jiwon.py" @@ -0,0 +1,27 @@ +import sys + +N, C = map(int, sys.stdin.readline().split()) +houses = [int(sys.stdin.readline()) for _ in range(N)] +houses.sort() + +max_distance = houses[-1]-houses[0] +s,e = 1, max_distance +result = 0 + +while s<=e: + cur = houses[0] + temp = 1 + m = (s+e)//2 + + for i in range(1,N): + if houses[i]-cur >= m: + cur = houses[i] + temp+=1 + + if temp >= C: + s = m+1 + result = m + else: + e = m-1 + +print(result) \ No newline at end of file From 5f25c777db1eed892e91836d8276b460b6b709ec Mon Sep 17 00:00:00 2001 From: kimgwon <92065911+kimgwon@users.noreply.github.com> Date: Sun, 8 Oct 2023 09:33:25 +0900 Subject: [PATCH 2/3] Create jiwon.py --- .../jiwon.py" | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 "Baekjoon - \353\254\270\354\240\234\355\222\200\354\235\264/\354\212\244\355\203\200\355\212\270\354\231\200 \353\247\201\355\201\254/jiwon.py" diff --git "a/Baekjoon - \353\254\270\354\240\234\355\222\200\354\235\264/\354\212\244\355\203\200\355\212\270\354\231\200 \353\247\201\355\201\254/jiwon.py" "b/Baekjoon - \353\254\270\354\240\234\355\222\200\354\235\264/\354\212\244\355\203\200\355\212\270\354\231\200 \353\247\201\355\201\254/jiwon.py" new file mode 100644 index 0000000..c474684 --- /dev/null +++ "b/Baekjoon - \353\254\270\354\240\234\355\222\200\354\235\264/\354\212\244\355\203\200\355\212\270\354\231\200 \353\247\201\355\201\254/jiwon.py" @@ -0,0 +1,30 @@ +import sys +from itertools import combinations + +N = int(sys.stdin.readline()) +values = [list(map(int, sys.stdin.readline().split())) for _ in range(N)] + +total = [i for i in range(N)] +teams = list(combinations(total,N//2)) +teams = teams[:len(teams)//2] +result = 100 + +for team in teams: + start = list(team) + link = [i for i in total if i not in start] + + start_comb = list(combinations(start,2)) + start_value = 0 + for i,j in start_comb: + start_value+=values[i][j] + start_value+=values[j][i] + + link_comb = list(combinations(link,2)) + link_value = 0 + for i,j in link_comb: + link_value+=values[i][j] + link_value+=values[j][i] + + result = min(result, abs(start_value-link_value)) + +print(result) \ No newline at end of file From 49b065c6487820954810a61bc74bb929ac686f69 Mon Sep 17 00:00:00 2001 From: kimgwon <92065911+kimgwon@users.noreply.github.com> Date: Sun, 8 Oct 2023 10:30:20 +0900 Subject: [PATCH 3/3] Create jiwon.py --- .../jiwon.py" | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 "Baekjoon - \353\254\270\354\240\234\355\222\200\354\235\264/\355\206\240\353\247\210\355\206\240/jiwon.py" diff --git "a/Baekjoon - \353\254\270\354\240\234\355\222\200\354\235\264/\355\206\240\353\247\210\355\206\240/jiwon.py" "b/Baekjoon - \353\254\270\354\240\234\355\222\200\354\235\264/\355\206\240\353\247\210\355\206\240/jiwon.py" new file mode 100644 index 0000000..5e24a21 --- /dev/null +++ "b/Baekjoon - \353\254\270\354\240\234\355\222\200\354\235\264/\355\206\240\353\247\210\355\206\240/jiwon.py" @@ -0,0 +1,59 @@ +import sys + +# M: 가로, N: 세로 +# 1:익, 0:노익, -1:없음 +M,N = map(int, sys.stdin.readline().split()) +tomatos = [] +all_1, cant_1 = True, True + +for _ in range(N): + t = list(map(int, sys.stdin.readline().split())) + tomatos.append(t) + + if all_1 and 0 in t: + all_1 = False + if cant_1 and 1 in t: + cant_1 = False + +if all_1: + print(0) + exit(1) +if cant_1: + print(-1) + exit(1) + +dx = [0,0,-1,1] +dy = [-1,1,0,0] + +def bfs(x,y): + for i in range(4): + new_x = x+dx[i] + new_y = y+dy[i] + + if new_x<0 or new_x>=M or new_y<0 or new_y>=N: + continue + + if tomatos[new_y][new_x] == -1: + continue + + tomatos[new_y][new_x] = 1 + print(tomatos) + +day = 0 + +while(True): + day+=1 + do = False + for i in range(N): + for j in range(M): + if tomatos[i][j]==1: + bfs(j,i) + + for tomato in tomatos: + if 0 in tomato: + do = True + + if not do: + break + +print(day) \ No newline at end of file