일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- lg디스플레이산학장학생
- LG인적성
- aws
- lg합격
- e1인턴
- SK인턴
- lg적성검사
- lg인재상
- cloudarchitecting
- lg인적성합격
- lg인성검사
- lgenius
- LG인적성후기
- 2022awscloud
- lg디스플레이lgenius
- 데이터분석
- SKT
- awscloudbootcamp
- aws클라우드부트캠프
- awsacademy
- LGD
- cloudfoundations
- lg인적성모의고사
- 2022awscloudbootcamp
- SKC&C
- LG디스플레이
- awscloud
- sk
- DT
- sktai
Archives
- Today
- Total
목록Coding Test/BaekJoon (3)
냥냥파워

https://www.acmicpc.net/problem/1874 1874번: 스택 수열 1부터 n까지에 수에 대해 차례로 [push, push, push, push, pop, pop, push, push, pop, push, push, pop, pop, pop, pop, pop] 연산을 수행하면 수열 [4, 3, 6, 8, 7, 5, 2, 1]을 얻을 수 있다. www.acmicpc.net n = int(input()) s = [] op = [] count = 1 temp = True for i in range(n): num = int(input()) while count
Coding Test/BaekJoon
2022. 6. 28. 14:07

힙을 두 개 써서 n을 분배해야 한다 왼쪽 힙은 최대 힙으로 정렬하고, 오른쪽 힙은 최소 힙으로 정렬하면 왼쪽 힙의 첫번째 요소는 항상 중앙값이다! import heapq, sys # 입력 받을 숫자의 개수 n = int(sys.stdin.readline()) # 최댓값, 최솟값 maxh, minh = [], [] # n번만큼 실행 for i in range(n): # 숫자 하나씩 입력 받기 num = int(sys.stdin.readline()) # 만약 maxh, minh 길이가 같은 경우 if len(maxh) == len(minh): # push heapq.heappush(maxh, (-1 * num)) # 만약 maxh, minh 길이가 다른 경우 else: heapq.heappush(minh,..
Coding Test/BaekJoon
2022. 6. 20. 14:36