일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- LSTM
- 그래프 이론
- Mask Processing
- dynamic programming
- opencv
- r-cnn
- Python
- Reinforcement Learning
- object detection
- real-time object detection
- MySQL
- BFS
- deep learning
- image processing
- AlexNet
- CNN
- dfs
- C++
- One-Stage Detector
- 강화학습
- MinHeap
- 딥러닝
- 머신러닝
- canny edge detection
- YoLO
- machine learning
- 백준
- DP
- eecs 498
- two-stage detector
- Today
- Total
목록1715 (2)
JINWOOJUNG

접근법 다른 두 수의 합으로 특정 수를 나타내는지를 확인하기 위해서는 특정 수 보다 작은 두 수를 선택해야 하기에 정렬이 필요하다. 또한, 이중 for문으로 직접 접근하기에는 두 수를 찾기 위한 while문이 추가적으로 필요하여 $O(n^3)$ 시간복잡도가 발생한다. 따라서 $nlogn$의 알고리즘이 필요하기에 quick sort에서 활용한 방식처럼 pointer를 이용하여 접근하였으며, 0과 자기자신이 더해져 다른 위치의 자기자신을 나타내는 예외사항을 처리하도록 노력하였다. 정답 import sys N = int(input()) arr = list(map(int,sys.stdin.readline().split(" "))) arr.sort() cnt = 0 for i in range(N): tmp = a..

접근법 최소 비교 횟수를 구하기 위해서는 입력받은 묶음의 크기를 정렬한 후 작은 2개의 묶음의 크기부터 더해나가서 계산할 수 있다. 따라서 양쪽으로 입출력이 가능한 deque 자료구조를 사용하여 구현하였다. from collections import deque N = int(input()) tmp = [] for i in range(N): tmp.append(int(input())) tmp.sort() queue = deque() for i in range(N): queue.append(tmp[i]) result = 0 for _ in range(1,N): a = queue.popleft() b = queue.popleft() result += a+b queue.appendleft(a+b) print(r..