diff --git a/mean71/python.ipynb b/mean71/python.ipynb index 44859eb..3df766b 100644 --- a/mean71/python.ipynb +++ b/mean71/python.ipynb @@ -469,6 +469,97 @@ "\n", "# 방탈출 https://www.acmicpc.net/problem/23352 g5\n" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 9주차" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import sys\n", + "import heapq\n", + "\n", + "he = [1,2,5,4,7]\n", + "heapq.heapify(he)\n", + "heapq.heappop(he)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# 평행선 https://www.acmicpc.net/problem/2358 s4\n", + "import sys\n", + "from collections import defaultdict\n", + "input = sys.stdin.readline\n", + "\n", + "x = defaultdict(int)\n", + "y = defaultdict(int)\n", + "cnt = 0\n", + "\n", + "for _ in range(int(input())): # 1 <= n <= 10^5\n", + " i, j = map(int, input().split()) # |x|,|y| < 2^31\n", + " x[i] += 1\n", + " y[j] += 1\n", + "\n", + "for i in x.values():\n", + " if i > 1:\n", + " cnt += 1\n", + "\n", + "for i in y.values():\n", + " if i > 1:\n", + " cnt += 1\n", + "\n", + "print(cnt)\n", + "\n", + "# 밥 https://www.acmicpc.net/problem/23559 g5\n", + "# 1 <= N <= 10^5, 1000N <= X <= 5000N\n", + "# 1 <= A,B <= 1000\n", + "import sys\n", + "import heapq\n", + "input = sys.stdin.readline\n", + "\n", + "N, X = map(int, input().split())\n", + "max_A = (X - 1000*N)//4000\n", + "total = 0\n", + "l_A = []\n", + "\n", + "\n", + "for _ in range(N):\n", + " A, B = map(int, input().split())\n", + " total += B\n", + " if A > B:\n", + " heapq.heappush(l_A, B - A)\n", + "\n", + "if len(l_A) <= max_A:\n", + " total -= sum(l_A)\n", + "else:\n", + " for _ in range(max_A):\n", + " total -= heapq.heappop(l_A)\n", + "\n", + "print(total)\n", + "\n", + "# 에너그램 https://www.acmicpc.net/problem/6443 g5\n", + "# 미해결 출력초과\n", + "import sys\n", + "from itertools import permutations\n", + "input = sys.stdin.readline\n", + "\n", + "for _ in range(int(input())): # n <= 10^5\n", + " word = input() # 1 <= len(word) <= 20\n", + " \n", + " for s in sorted(set(permutations(word))):\n", + " print(\"\".join(s))" + ] } ], "metadata": { @@ -487,7 +578,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.13.1" + "version": "3.11.8" } }, "nbformat": 4,