From 6b8a5a13081d81c349b5360b039bfe9117d74ce8 Mon Sep 17 00:00:00 2001 From: songyc macbook Date: Tue, 10 Feb 2026 22:47:47 +0900 Subject: [PATCH] baekjoon 20260210 --- code_study/Baekjoon/python/1202.py | 34 ++++++++++++++++++++++++++++++ code_study/Baekjoon/python/2721.py | 8 +++++++ 2 files changed, 42 insertions(+) create mode 100644 code_study/Baekjoon/python/1202.py create mode 100644 code_study/Baekjoon/python/2721.py diff --git a/code_study/Baekjoon/python/1202.py b/code_study/Baekjoon/python/1202.py new file mode 100644 index 0000000..1554238 --- /dev/null +++ b/code_study/Baekjoon/python/1202.py @@ -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) \ No newline at end of file diff --git a/code_study/Baekjoon/python/2721.py b/code_study/Baekjoon/python/2721.py new file mode 100644 index 0000000..d65d129 --- /dev/null +++ b/code_study/Baekjoon/python/2721.py @@ -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)))) \ No newline at end of file