일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
- python
- Java
- AIVLE
- 골드
- 파이썬
- KT에이블스쿨
- dp
- 정렬
- 딕셔너리
- kt에이블스쿨5기
- Level3
- Level1
- 트리
- dfs
- Level2
- AI트랙
- 실버
- join
- sql
- 백준
- 알고리즘
- KT 에이블스쿨
- 그래프
- BFS
- 티스토리챌린지
- 프로그래머스
- 오블완
- 패스트캠퍼스
- spring
- 구현
- Today
- Total
목록티스토리챌린지 (15)
rose_brown

1. 문제https://www.acmicpc.net/problem/11049 2. 코드pythonimport sysinput = sys.stdin.readlineN = int(input())M = []D = [[-1 for j in range(N+1)]for i in range(N+1)]M.append((0, 0))for i in range(N): r, c = map(int, input().split()) M.append((r, c))def execute(s, e): result = sys.maxsize if D[s][e] != -1: return D[s][e] if s == e: return 0 if s + 1 == e: return..

1. 문제https://www.acmicpc.net/problem/1655 2. 코드 답안import sysimport heapqinput = sys.stdin.readlinex = int(input())max_h, min_h = [], []for i in range(x): num = int(input()) if len(max_h) == len(min_h): heapq.heappush(max_h, -num) else: heapq.heappush(min_h, num) if len(max_h) >= 1 and len(min_h) >= 1 and max_h[0] * -1 > min_h[0]: max_value = heapq.heappop(max_h) ..

1. 문제https://www.acmicpc.net/problem/1915 2. 코드pythonimport sysinput = sys.stdin.readlinen, m = map(int, input().split())D = [[0 for j in range(1001)] for i in range(1001)]MAX = 0for i in range(0, n): num = list(input()) for j in range(0, m): D[i][j] = int(num[j]) if D[i][j] == 1 and j > 0 and i > 0: D[i][j] = min(D[i-1][j-1], D[i][j-1], D[i-1][j]) + D[i][j] ..

1. 문제https://www.acmicpc.net/problem/10844 2. 코드pythonimport sysinput = sys.stdin.readlineN = int(input())mod = 1000000000D = [[0 for j in range(11)]for i in range(N+1)]for i in range(1, 10): D[1][i] = 1for i in range(2, N+1): D[i][0] = D[i-1][1] D[i][9] = D[i-1][8] for j in range(1, 9): D[i][j] = (D[i-1][j-1] + D[i-1][j+1]) % modsum = 0for i in range(10): sum = (sum + D[N]..

1. 문제https://www.acmicpc.net/problem/1463 2. 코드pythonimport sysinput = sys.stdin.readlineN = int(input())D = [0] * (N+1)D[1] = 0for i in range(2, N+1): D[i] = D[i-1] + 1 if i % 2 == 0: D[i] = min(D[i], D[i//2] + 1) if i % 3 == 0: D[i] = min(D[i], D[i//3] + 1)print(D[N])풀이N - 구하고자 하는 수, D - 연산 횟수 최솟값을 저장하는 DP테이블D[1] = 0for i → 2 ~ ND[i] = D[i-1] + 1 ⇒ -1 연산 표현if 2의 배수D[i/2]..

1. 문제https://www.acmicpc.net/problem/1256 2. 코드pythonimport sysinput = sys.stdin.readlineN, M, K = map(int, input().split())D = [[0 for j in range(202)] for i in range(202)]for i in range(0, 201): for j in range(0, i+1): if j == 0 or j == i: D[i][j] = 1 else: D[i][j] = D[i-1][j-1] + D[i-1][j] if D[i][j] > 1000000000: D[i][j] = 1000..

1. 문제https://www.acmicpc.net/problem/1722 2. 코드pythonimport sysinput = sys.stdin.readlineF = [0] * 21S = [0] * 21visited = [False] * 21N = int(input())F[0] = 1# F 초기화for i in range(1, N+1): F[i] = F[i-1] * iinputList = list(map(int, input().split()))if inputList[0] == 1: K = inputList[1] for i in range(1, N+1): cnt = 1 for j in range(1, N+1): if visited[j]: ..

1. 문제https://www.acmicpc.net/problem/13251 2. 코드pythonimport sysinput = sys.stdin.readlineM = int(input())D = list(map(int, input().split()))K = int(input())T = 0probability = [0] * 51count = 0for i in range(0, M): T += D[i]for i in range(0, M): if D[i] >= K: probability[i] = 1 for k in range(0, K): probability[i] = probability[i] * (D[i]-k) / (T-k) count +=..

1. 문제https://www.acmicpc.net/problem/11050 2. 코드 답안python 1from math import factorialx,y = map(int,input().split())result = factorial(x) // (factorial(y) * factorial(x-y))print(result) python 2import sysinput = sys.stdin.readlineN, K = map(int, input().split())D = [[0 for j in range(N+1)]for i in range(N+1)]for i in range(0, N+1): D[i][1] = i D[i][0] = 1 D[i][i] = 1for i in range(2, N+1..

1. 문제https://www.acmicpc.net/problem/11438 2. 코드import sysfrom collections import dequeinput = sys.stdin.readlineprint = sys.stdout.writeN = int(input())tree = [[0] for _ in range(N+1)]for _ in range(0, N-1): s, e = map(int, input().split()) tree[s].append(e) tree[e].append(s)visited = [False] * (N+1)depth = [0] * (N+1)temp = 1kmax = 0while temp depth[b]: temp = a a = b ..