From 92dbdd3c09ad93f59574ce742ca3cfe5dc577e8d Mon Sep 17 00:00:00 2001 From: JaeIn1 <97165077+JaeIn1@users.noreply.github.com> Date: Mon, 21 Jul 2025 20:09:00 +0900 Subject: [PATCH] =?UTF-8?q?[20250721]=20BAJ=20/=20=EC=8B=A4=EB=B2=841=20/?= =?UTF-8?q?=20=EC=97=B0=EC=82=B0=EC=9E=90=20=EB=81=BC=EC=9B=8C=EB=84=A3?= =?UTF-8?q?=EA=B8=B0=20/=20=EC=9D=B4=EC=9E=AC=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...74\354\233\214\353\204\243\352\270\260.md" | 44 +++++++++++++++ JaeIn/202507/test.py | 53 ------------------- 2 files changed, 44 insertions(+), 53 deletions(-) create mode 100644 "JaeIn/202507/21 BAJ \354\227\260\354\202\260\354\236\220 \353\201\274\354\233\214\353\204\243\352\270\260.md" delete mode 100644 JaeIn/202507/test.py diff --git "a/JaeIn/202507/21 BAJ \354\227\260\354\202\260\354\236\220 \353\201\274\354\233\214\353\204\243\352\270\260.md" "b/JaeIn/202507/21 BAJ \354\227\260\354\202\260\354\236\220 \353\201\274\354\233\214\353\204\243\352\270\260.md" new file mode 100644 index 0000000..b361df8 --- /dev/null +++ "b/JaeIn/202507/21 BAJ \354\227\260\354\202\260\354\236\220 \353\201\274\354\233\214\353\204\243\352\270\260.md" @@ -0,0 +1,44 @@ +```python +import sys +input = sys.stdin.readline + +N = int(input()) +numbers = list(map(int, input().split())) +op = list(map(int, input().split())) + +max_num = float("-inf") +min_num = float("inf") + +def dfs(n, cur_sum): + + global max_num, min_num + + if n == N - 1: + max_num = max(max_num, cur_sum) + min_num = min(min_num, cur_sum) + return + + + if op[0] > 0: # 덧셈 + op[0] -= 1 + dfs(n + 1 , cur_sum + numbers[n + 1]) + op[0] += 1 + if op[1] > 0: # 뺄셈 + op[1] -= 1 + dfs(n + 1 , cur_sum - numbers[n + 1]) + op[1] += 1 + if op[2] > 0: # 곱하기 + op[2] -= 1 + dfs(n + 1 , cur_sum * numbers[n + 1]) + op[2] += 1 + if op[3] > 0: # 나누기 + op[3] -= 1 + dfs(n + 1 , int(cur_sum / numbers[n + 1])) + op[3] += 1 + + +dfs(0 , numbers[0]) +print(max_num) +print(min_num) + +``` diff --git a/JaeIn/202507/test.py b/JaeIn/202507/test.py deleted file mode 100644 index 151cd0c..0000000 --- a/JaeIn/202507/test.py +++ /dev/null @@ -1,53 +0,0 @@ -import sys -import heapq -from collections import defaultdict - -input = sys.stdin.readline - -test_case = int(input()) - -for _ in range(test_case): - N = int(input()) - max_heap = [] - min_heap = [] - count_mp = defaultdict(int) - - for i in range(N): - char, num = input().split() - num = int(num) - - if char == 'I': - heapq.heappush(max_heap, -num) - heapq.heappush(min_heap, num) - count_mp[num] += 1 - - elif char == 'D': - if num == 1: - while max_heap and count_mp[-max_heap[0]] == 0: - heapq.heappop(max_heap) - - if max_heap: - removed = -heapq.heappop(max_heap) - count_mp[removed] -= 1 - - elif num == -1: - - while min_heap and count_mp[min_heap[0]] == 0: - heapq.heappop(min_heap) - - if min_heap: - removed = heapq.heappop(min_heap) - count_mp[removed] -= 1 - - - while max_heap and count_mp[-max_heap[0]] == 0: - heapq.heappop(max_heap) - - while min_heap and count_mp[min_heap[0]] == 0: - heapq.heappop(min_heap) - - - if max_heap and min_heap: - print(f"{-max_heap[0]} {min_heap[0]}") - else: - print("EMPTY") \ No newline at end of file