Skip to content

Commit 23768e9

Browse files
authored
[박희경] 63차 라이브 코테 제출 (#517)
* 61차 1번 문제 풀이 * 61차 2번 문제 풀이 * 61차 3번 문제 풀이 (푸는 중) * 61차 3번 문제 다시 풀이 * 62차 1번 문제 풀이 * 62차 2번 문제 풀이 * 62차 3번 문제 풀이 * 63차 1번 문제 풀이 * 63차 2번 문제 풀이 * 63차 3번 문제 풀이
1 parent 365f938 commit 23768e9

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

live6/test63/문제1/박희경.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import sys
2+
3+
input = sys.stdin.readline
4+
5+
n, k = map(int, input().split())
6+
c = list(map(int, input().split()))
7+
8+
sliding_window = []
9+
start, end = 0, k - 1
10+
sum_value = sum(c[start:end + 1])
11+
sliding_window.append(sum_value)
12+
13+
14+
while end < n:
15+
sum_value -= c[start]
16+
start += 1
17+
end += 1
18+
if end < n:
19+
sum_value += c[end]
20+
sliding_window.append(sum_value)
21+
22+
print(max(sliding_window))
23+
24+
25+
"""
26+
10 2
27+
3 -2 -4 -9 0 3 7 13 8 -3
28+
29+
10 5
30+
3 -2 -4 -9 0 3 7 13 8 -3
31+
"""

live6/test63/문제2/박희경.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import sys
2+
3+
input = sys.stdin.readline
4+
5+
n = int(input())
6+
ranks = []
7+
for _ in range(n):
8+
ranks.append(int(input()))
9+
10+
res = 0
11+
for real, hope in enumerate(sorted(ranks), start=1):
12+
res += abs(real - hope)
13+
print(res)
14+
15+
16+
"""
17+
5
18+
1
19+
5
20+
3
21+
1
22+
2
23+
"""

live6/test63/문제3/박희경.py

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

0 commit comments

Comments
 (0)