파이썬59 [백준 10816] 숫자 카드 2 - Python(파이썬) from collections import Counter import sys N = int(sys.stdin.readline().strip()) N_data = sorted(map(int, sys.stdin.readline().split())) M = int(sys.stdin.readline().strip()) M_data = list(map(int, sys.stdin.readline().split())) result = Counter(N_data) for m in M_data: print(result[m], end=' ') 2021. 2. 20. [백준 1654] 랜선 자르기 - Python(파이썬) import sys K, N = map(int, sys.stdin.readline().split()) lines = [] for k in range(K): data = int(sys.stdin.readline().strip()) lines.append(data) start, end = 1, max(lines) while start = N: break if cnt >= N: start = mid + 1 else: end = mid - 1 print(end) 2021. 2. 20. [백준 1920] 수 찾기 - Python(파이썬) from bisect import bisect import sys N = int(sys.stdin.readline().strip()) A = list(map(int, sys.stdin.readline().split())) M = int(sys.stdin.readline().strip()) M_data = list(map(int, sys.stdin.readline().split())) A.sort() for m in M_data: i = bisect(A, m) - 1 if i != len(A) and A[i] == m: print(1) else: print(0) 2021. 2. 20. [백준 2110] 공유기 설치 - Python(파이썬) import sys N, C = map(int, sys.stdin.readline().split()) houses = [] for n in range(N): houses.append(int(sys.stdin.readline().strip())) houses.sort() start, end = 1, houses[-1] - houses[0] ans = 0 while start = x + gap: cnt += 1 x = houses[i] if cnt >= C: start = gap + 1 ans = gap else: end = gap - 1 print(ans) 2021. 2. 20. [백준 5430] AC - Python(파이썬) import sys T = int(sys.stdin.readline().strip()) for _ in range(T): my_f = sys.stdin.readline().strip() n = int(sys.stdin.readline().strip()) data = sys.stdin.readline().strip()[1:-1].split(',') rev = False f, b = 0, 0 for ff in my_f: if ff == 'R': rev = True if not rev else False else: if rev: b += 1 else: f += 1 if f + b > n: print('error') else: data = data[f:n - b] if rev: print('[' + ','.jo.. 2021. 2. 15. [백준 1021] 회전하는 큐 - Python(파이썬) from collections import deque import sys N, M = map(int, sys.stdin.readline().split()) data = deque(map(int, sys.stdin.readline().split())) my_d = deque(range(1, N+1)) idx = 0 ans = 0 for _ in range(M): find_idx = my_d.index(data[0]) ans += min(abs(find_idx - idx), abs(len(my_d) - abs(find_idx - idx))) my_d.remove(data[0]) data.popleft() idx = find_idx print(ans) 2021. 2. 15. 이전 1 ··· 6 7 8 9 10 다음