Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 92 additions & 1 deletion mean71/python.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -487,7 +578,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.1"
"version": "3.11.8"
}
},
"nbformat": 4,
Expand Down