Skip to content

Commit 7462b7b

Browse files
authored
Merge pull request #525 from gmlrude/main
[박희경] 64차 라이브 코테 제출
2 parents 5743995 + b9a4685 commit 7462b7b

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import sys
2+
from itertools import *
3+
4+
input = sys.stdin.readline
5+
6+
n = sorted(list(map(str, input().rstrip())), reverse=True)
7+
sum = 0
8+
9+
if '0' not in n:
10+
print(-1)
11+
else:
12+
for i in n:
13+
sum += int(i)
14+
if sum % 3 == 0:
15+
print(''.join(n))
16+
else:
17+
print(-1)

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+
3+
input = sys.stdin.readline
4+
5+
n, k = map(int, input().split())
6+
g = []
7+
x = []
8+
9+
for _ in range(n):
10+
a, b = map(int, input().split())
11+
g.append(a)
12+
x.append(b)
13+
14+
15+
bucket = [0] * (max(x) + 1)
16+
for i in range(n):
17+
bucket[x[i]] = g[i]
18+
19+
# [0, 5, 2, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 10]
20+
start, end = 0, k*2+1
21+
ice = max_ice = sum(bucket[start:end+1])
22+
23+
while end < len(bucket) - 1:
24+
end += 1
25+
ice += bucket[end]
26+
ice -= bucket[start]
27+
start += 1
28+
29+
max_ice = max(max_ice, ice)
30+
31+
print(max_ice)

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from collections import deque
2+
3+
4+
def solution(cacheSize, cities):
5+
ans = 0
6+
if cacheSize == 0:
7+
return len(cities) * 5
8+
9+
cache = deque(maxlen=cacheSize)
10+
11+
for city in cities:
12+
city = city.lower()
13+
if city in cache:
14+
ans += 1
15+
cache.remove(city) # (놓친 부분) LRU 이기 때문에 새로 다시 캐싱
16+
cache.append(city)
17+
else:
18+
ans += 5
19+
cache.append(city)
20+
21+
return ans

0 commit comments

Comments
 (0)