| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
- bfs
- level 3
- SQL
- Lv. 3
- 백준
- SQL 고득점 KIT
- Dynamic Programming
- 자바스크립트
- programmers
- Lv. 2
- Lv. 0
- 프로그래머스
- Baekjoon
- softeer
- Lv. 1
- dfs
- 소프티어
- 오블완
- group by
- 파이썬
- 동적계획법
- DP
- 너비 우선 탐색
- join
- 깊이 우선 탐색
- 티스토리챌린지
- javascript
- Java
- Python
- LEVEL 2
- Today
- Total
목록Python (145)
몸과 마음이 건전한 SW 개발자
문제 링크https://www.acmicpc.net/problem/3273정답 코드n = int(input())arr = sorted(list(map(int, input().split())))val = int(input())left = 0right = n - 1answer = 0while left val: right -= 1 else: left += 1print(answer)풀이 방법투 포인터를 사용했다.정렬한 배열의 좌 우측에서 값을 가져온다.값이 원하는 값과 같다면 좌를 키우고 우를 낮춰서 범위를 줄여준다.값이 작다면 좌측에서 값을 키워야 하므로 좌를 키운다.값이 크다면 우측에서 값을 낮춰야 하므로 우를 낮춘다.좌우 값이 같지 않을 때 까지 한다.인덱스가 겹치지 않는 ..
문제 링크https://www.acmicpc.net/problem/2565정답 코드import sysinput = sys.stdin.readlinen = int(input())lines = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x:x[1])dp = [1] * nfor i in range(1, n): si, ti = lines[i] for j in range(i): sj, tj = lines[j] if sj 풀이 방법 입력 처리 및 정렬(시작점, 끝점)을 입력받고 끝나는 지점 기준으로 정렬한다.정렬은 그리디 + DP 조합을 활용하기 위한 사전 작업이다.DP 배열 정의 및 초기화dp[..
문제 링크https://www.acmicpc.net/problem/12919정답 코드s = input()t = input()lenS = len(s)lenT = len(t)answer = 0def isIncluded(arr): normarlString = "".join(arr) reversString = "".join(arr[::-1]) return normarlString in t or reversString in tdef dfs(length, arr): global answer if answer: return if length == lenT: string = "".join(arr) if string == t: an..
문제 링크https://www.acmicpc.net/problem/10830정답 코드import sysinput = sys.stdin.readlinen, b = map(int, input().split())matrix = [list(map(int, input().split())) for _ in range(n)]optimization = dict()# matrix의 원소가 1000이하이기 때문에 처음부터 걸러준다.for i in range(n): for j in range(n): matrix[i][j] %= 1000optimization[1] = matrix# cal = calculationdef cal(leftM, rightM): newM = [[0] * n for _ in ra..
문제 링크https://www.acmicpc.net/problem/12865정답 코드import sysinput = sys.stdin.readlinen, k = map(int, input().split())dp = [[0] * (k+1) for _ in range(n+1)]for i in range(1, n+1): w, v = map(int, input().split()) for j in range(1, k+1): if j >= w: dp[i][j] = max(v+dp[i-1][j-w], dp[i-1][j]) else: dp[i][j] = dp[i-1][j]print(dp[n][k])풀이 방법DP 배열의 의미:dp[i][j]dp[..
문제 링크https://www.codetree.ai/trails/complete/curated-cards/challenge-group-same-word/description Code Tree | Learning to Code with ConfidenceA super-comprehensive, meticulously arranged Coding Learning Curriculum engineered by Algorithm Experts composed of former International Olympiad in Informatics (IOI) medalists.www.codetree.ai정답 코드import sysinput = sys.stdin.readlinen = int(input())words = ..