Skip to content

Commit 829b301

Browse files
committed
Merge branch 'kcmBOJHW' of https://github.com/JavaJobJava/CodingTest into kcmBOJHW
2 parents 632bfba + 32c2f34 commit 829b301

File tree

3 files changed

+61
-8
lines changed

3 files changed

+61
-8
lines changed

cmkim/BaekJoon/백준_1202.py

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,40 @@
1+
import heapq
2+
import sys
3+
input = sys.stdin.readline
14
n, k = map(int, input().split())
2-
jewel = [[0, 0] for _ in range(n)]
3-
bag = [0 for _ in range(k)]
5+
6+
jewel = []
7+
bags = []
8+
49
for i in range(n):
5-
jewel[i] = list(map(int, input().split()))
10+
w, v = map(int, input().split())
11+
heapq.heappush(jewel, (w, v))
612

713
for i in range(k):
8-
bag[i] = int(input())
14+
heapq.heappush(bags, int(input()))
15+
16+
result = 0
17+
selected = []
18+
for _ in range(k):
19+
bags_weight = heapq.heappop(bags)
20+
21+
while jewel and bags_weight >= jewel[0][0]:
22+
tmp = heapq.heappop(jewel)
23+
w, v = tmp[0], tmp[1]
24+
heapq.heappush(selected, -v)
25+
26+
if selected:
27+
result -= heapq.heappop(selected)
928

10-
print(jewel)
11-
print(bag)
29+
print(result)
30+
'''
31+
4 4
32+
1 100
33+
2 200
34+
13 300
35+
10 500
36+
14
37+
3
38+
12
39+
1
40+
'''

cmkim/BaekJoon/백준_1541.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
arr = input().split('-')
2+
num = []
3+
4+
for i in arr:
5+
if '+' in i:
6+
sum = 0
7+
temp = i.split('+')
8+
9+
for i in range(len(temp)):
10+
sum += int(temp[i])
11+
else:
12+
sum = i
13+
14+
num.append(int(sum))
15+
16+
result = num[0]
17+
if len(num) > 1:
18+
for i in range(1,len(num)):
19+
20+
result -= num[i]
21+
22+
print(result)

cmkim/BaekJoon/백준_2533.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
22
input = sys.stdin.readline
3+
34
sys.setrecursionlimit(10**9)
45
n = int(input())
56
tree = [[] for _ in range(n+1)]
@@ -12,7 +13,7 @@
1213
tree[a].append(b)
1314
tree[b].append(a)
1415

15-
#print(tree)
16+
1617

1718
def bfs(root):
1819
visited[root] = True
@@ -27,4 +28,5 @@ def bfs(root):
2728

2829
bfs(1)
2930

30-
print(min(dp[1][0], dp[1][1]))
31+
print(min(dp[1][0], dp[1][1]))
32+

0 commit comments

Comments
 (0)