Skip to content

Commit b1382da

Browse files
authored
[김진용] 63차 라이브 코테 제출 (#516)
* 61차 1번 문제풀이 * 61차 2번 문제풀이 * 61차 3번 문제풀이 * 61차 문제 3번 다시 풀기 * 62차 1번 문제풀이 * 62차 2번 문제풀이 * 문제 2 수정 * 62차 3번 문제풀이 * 63차 1번 문제풀이 * 63차 2번 문제풀이 * 63차 문제 3번 문제풀이
1 parent 23768e9 commit b1382da

File tree

4 files changed

+92
-0
lines changed

4 files changed

+92
-0
lines changed

live6/test62/문제3/김진용.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
def solution(n, words):
2+
ary = []
3+
people = 1
4+
cnt = 1
5+
ary.append(words[0])
6+
for i in range(1, len(words)):
7+
# print(cnt, people, words[i])
8+
people += 1
9+
if people % n == 0:
10+
people = n
11+
else:
12+
people = people%n
13+
if words[i][0] != words[i-1][-1] or words[i] in ary:
14+
# print(words[i][0], words[i-1][-1])
15+
return [people, cnt]
16+
else:
17+
ary.append(words[i])
18+
if people == n:
19+
cnt += 1
20+
return [0, 0]
21+
22+
23+
24+
print(solution(3, ["tank", "kick", "know", "wheel", "land", "dream", "mother", "robot", "tank"]))
25+
print(solution(5,
26+
["hello", "observe", "effect", "take", "either", "recognize", "encourage", "ensure", "establish", "hang",
27+
"gather", "refer", "reference", "estimate", "executive"]))
28+
print(solution(2, ["hello", "one", "even", "never", "now", "world", "draw"]))

live6/test63/문제1/김진용.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
n, k = map(int, input().split())
2+
ary = list(map(int, input().split()))
3+
start = 0
4+
end = k-1
5+
s_w = sum(ary[:k])
6+
result = []
7+
result.append(s_w)
8+
while end < len(ary)-1:
9+
s_w -= ary[start]
10+
start += 1
11+
end += 1
12+
s_w += ary[end]
13+
result.append(s_w)
14+
print(max(result))

live6/test63/문제2/김진용.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import sys
2+
input = sys.stdin.readline
3+
n = int(input())
4+
ary = []
5+
ary_2 = []
6+
for i in range(n):
7+
ary.append(i+1)
8+
ary_2.append(int(input()))
9+
ary_2.sort()
10+
11+
result = 0
12+
for i in range(n):
13+
result += abs(ary[i] - ary_2[i])
14+
print(result)

live6/test63/문제3/김진용.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import math
2+
3+
4+
def solution(N, road, K):
5+
result = 0
6+
7+
city = [[math.inf]*(N+1) for _ in range(N + 1)]
8+
9+
for r in road:
10+
x, y, t = r[0], r[1], r[2]
11+
12+
if city[x][y] != math.inf:
13+
city[x][y] = min(city[x][y], t)
14+
if city[y][x] != math.inf:
15+
city[y][x] = min(city[y][x], t)
16+
else:
17+
city[x][y] = t
18+
city[y][x] = t
19+
for k in range(1, N + 1):
20+
for i in range(1, N + 1):
21+
for j in range(1, N + 1):
22+
if city[i][k] != math.inf and city[k][j] != math.inf:
23+
city[i][j] = min(city[i][j], city[i][k] + city[k][j])
24+
if i == j:
25+
city[i][j] = 0
26+
27+
for c in city[1]:
28+
if c <= K:
29+
result += 1
30+
31+
return result
32+
33+
34+
35+
print(solution(5, [[1, 2, 1], [2, 3, 3], [5, 2, 2], [1, 4, 2], [5, 3, 1], [5, 4, 2]], 3))
36+
print(solution(6, [[1, 2, 1], [1, 3, 2], [2, 3, 2], [3, 4, 3], [3, 5, 2], [3, 5, 3], [5, 6, 1]], 4))

0 commit comments

Comments
 (0)