분류 전체보기 720

[OS] 메모리 관리

이화여대 반효경 교수님의 강의를 보며 정리했습니다. 결론은 메모리관리 영역에서 가상메모리나 swap부분을 제외하고 운영체제의 역할은 미미하다는 것. 메모리접근, 물리 주소 할당등은 MMU나 TLB의 영역이라는 것. 메모리관리 메모리접근, 주소 변환에서 운영체제의 역할은 하나도 없음 전부 하드웨어의 영역. 운영체제는 I / O 접근만 관여함. 주소 논리 주소(Logical Address = virtual address) 프로세스마다 독립적으로 가지는 주소 공간 각 프로세스마다 0번지부터 시작 CPU가 보는 주소는 logical address임 물리 주소(Physical address) 메모리에 실제 올라가는 위치 주소 바인딩 : 주소를 결정하는 것. Symbolic Address -> Logical Add..

[codeforce][Python] #690 E2. Close Tuples (hard version)

시간초과가 나오는 code이다. import sys input = sys.stdin.readline from bisect import bisect_right from math import factorial MOD = int(1e9) + 7 for test in range(int(input())): n, m, k = map(int, input().split()) arr = list(map(int, input().split())) arr.sort() done = {} answer = 0 for i in range(n - m + 1): if arr[i] not in done: right = bisect_right(arr, arr[i] + k) done[arr[i]] = right length = done[ar..

[codeforce][Python] #690 E1. Close Tuples (easy version)

map으로 나보다 2큰수의 위치를 저장해둔 후 거기까지 사이의 갯수에서 나포함 3개를 뽑으면 된다. import sys input = sys.stdin.readline from bisect import bisect_left for test in range(int(input())): n = int(input()) arr = list(map(int, input().split())) arr.sort() done = {} answer = 0 for i in range(n - 2): if arr[i] not in done: right = bisect_left(arr, arr[i] + 3) done[arr[i]] = right length = done[arr[i]] - i if length > 2: length -..

[codeforce][Python] #690 D. Add to Neighbour and Remove

어떻게 표현할 것인가? 결국 total값의 약수가 되어야지 가능하다. import sys input = sys.stdin.readline for test in range(int(input())): n = int(input()) arr = list(map(int, input().split())) total = sum(arr) candidate = [num for num in range(1, total + 1) if not total % num] for target in candidate: tmp, answer = 0, 0 for num in arr: tmp += num answer += 1 if tmp == target: tmp = 0 answer -= 1 elif tmp > target: break el..

카테고리 없음 2021.12.07

[codeforce][Python] #690 C. Unique Number

숫자의 합이 되는 최소 길이의 숫자조합을 구합니다. 최소길이이므로 큰수부터 빼주며 숫자를 만들면 됩니다. 1~45까지의 모든 수는 표현이 가능하다는 것만 이해하면 됩니다. import sys input = sys.stdin.readline for test in range(int(input())): x = int(input()) answer, flag = '', 0 for num in range(9, 0, -1): if x >= num: x -= num answer += str(num) if not x: print(answer[::-1]) break else: print(-1)

[codeforce][Python] #690 B. Last Year's Substring

2020을 한번만 제외하고 만들 수 있는지 여부를 확인하는 문제입니다. 중간에 한번밖에 못띄우니 앞, 뒤에 2020의 모든 숫자가 존재해야합니다. import sys input = sys.stdin.readline for test in range(int(input())): n = int(input()) s = input().rstrip() answer = '2020' if s[0] + s[-3:] == answer or s[:2] + s[-2:] == answer or s[:3] + s[-1] == answer or s[:4] == answer or s[-4:] == answer: print("YES") else: print("NO")

[Programmers][Python][2021 카카오 인턴십] 표 편집

우선순위 큐 두개를 이용해 가운데값을 k로 운용했습니다. 마지막에 left를 right로 굳이 안옮겨도됐을텐데 조금 아쉽습니다. 또 set을 썼으면 좀 더 출력부분이 깔끔한 반복문으로 처리됐을 것 같습니다. 다른 분들은 연결리스트를 구현하신분들이 많았습니다. from heapq import heappop, heappush def solution(n, k, cmd): left, right, delete = [-i for i in range(k-1, -1, -1)], [i for i in range(k, n)], [] for command in cmd: c, *num = command.split() if c == 'U': cnt = int(num.pop()) for _ in range(cnt): heappu..