Skip to content

Commit cfa0653

Browse files
authored
Merge pull request #521 from kingjinyong/main
[김진용] 64차 라이브 코테 제출
2 parents ceb9fe7 + 9eaa50b commit cfa0653

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from itertools import *
2+
3+
n = list(input())
4+
n.sort(reverse=True)
5+
6+
number = int(''.join(n))
7+
8+
if number % 30 != 0:
9+
print(-1)
10+
else:
11+
print(number)

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)

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from collections import deque
2+
3+
4+
def solution(cacheSize, cities):
5+
result = 0
6+
if cacheSize == 0: return len(cities) * 5
7+
q = deque(maxlen=cacheSize)
8+
9+
cities = [c.lower() for c in cities]
10+
11+
for city in cities:
12+
if city not in q:
13+
q.append(city)
14+
result += 5
15+
else:
16+
q.remove(city)
17+
q.append(city)
18+
result += 1
19+
20+
return result
21+
22+
23+
print(solution(3, ["Jeju", "Pangyo", "Seoul", "NewYork", "LA", "Jeju", "Pangyo", "Seoul", "NewYork", "LA"]))
24+
print(solution(3, ["Jeju", "Pangyo", "Seoul", "Jeju", "Pangyo", "Seoul", "Jeju", "Pangyo", "Seoul"]))
25+
print(solution(2, ["Jeju", "Pangyo", "Seoul", "NewYork", "LA", "SanFrancisco", "Seoul", "Rome", "Paris", "Jeju", "NewYork", "Rome"] ))
26+
print(solution(5, ["Jeju", "Pangyo", "Seoul", "NewYork", "LA", "SanFrancisco", "Seoul", "Rome", "Paris", "Jeju", "NewYork", "Rome"] ))
27+
print(solution(2, ["Jeju", "Pangyo", "NewYork", "newyork"] ))
28+
print(solution(0, ["Jeju", "Pangyo", "Seoul", "NewYork", "LA"] ))

0 commit comments

Comments
 (0)