Skip to content

Commit c453918

Browse files
committed
64차 2번 문제풀이
1 parent 3032bd3 commit c453918

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import sys
2+
input = sys.stdin.readline
3+
4+
N, K = map(int,input().split())
5+
ary = []
6+
max_l = -1
7+
8+
for _ in range(N):
9+
g, x = map(int, input().split())
10+
max_l = max(max_l, x)
11+
ary.append([g, x])
12+
13+
ary_2 = [0] * (max_l+1)
14+
15+
for a in ary:
16+
ary_2[a[1]] = a[0]
17+
18+
start = 0
19+
end = K*2 + 1
20+
max_ary = -1
21+
22+
23+
sum_f = sum(ary_2[start:end])
24+
max_ary = max(max_ary, sum_f)
25+
while end < len(ary_2):
26+
sum_f -= ary_2[start]
27+
sum_f += ary_2[end]
28+
max_ary = max(max_ary, sum_f)
29+
start += 1
30+
end += 1
31+
print(max_ary)

0 commit comments

Comments
 (0)