baekjoon 20260210
This commit is contained in:
parent
8a4ad949fa
commit
6b8a5a1308
34
code_study/Baekjoon/python/1202.py
Normal file
34
code_study/Baekjoon/python/1202.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import sys
|
||||||
|
import heapq
|
||||||
|
|
||||||
|
input = sys.stdin.readline
|
||||||
|
|
||||||
|
jewels = []
|
||||||
|
bags = []
|
||||||
|
|
||||||
|
N, K = map(int, input().split())
|
||||||
|
|
||||||
|
for _ in range(N) :
|
||||||
|
m, v = map(int, input().split())
|
||||||
|
jewels.append((-v, m))
|
||||||
|
|
||||||
|
for _ in range(K) :
|
||||||
|
bags.append(int(input()))
|
||||||
|
|
||||||
|
jewels.sort(key = lambda x: (x[1], x[0]))
|
||||||
|
bags.sort()
|
||||||
|
|
||||||
|
pq = []
|
||||||
|
ans = 0
|
||||||
|
idx = 0
|
||||||
|
|
||||||
|
for bag in bags :
|
||||||
|
while idx < N and jewels[idx][1] <= bag :
|
||||||
|
heapq.heappush(pq, jewels[idx][0])
|
||||||
|
idx += 1
|
||||||
|
|
||||||
|
if pq :
|
||||||
|
cost = heapq.heappop(pq)
|
||||||
|
ans -= cost
|
||||||
|
|
||||||
|
print(ans)
|
||||||
8
code_study/Baekjoon/python/2721.py
Normal file
8
code_study/Baekjoon/python/2721.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
ans = []
|
||||||
|
for _ in range(int(input())) :
|
||||||
|
temp = 0
|
||||||
|
for k in range(1, int(input())+1) :
|
||||||
|
temp += k*(k+1)*(k+2)
|
||||||
|
ans.append(temp//2)
|
||||||
|
|
||||||
|
print('\n'.join(list(map(str, ans))))
|
||||||
Loading…
x
Reference in New Issue
Block a user