분류 전체보기 (402) 썸네일형 리스트형 [백준 15824번] 너 봄에는 캡사이신이 맛있단다 (Python3) 재미있는 문제였다. 이 문제는 특이하게도 N의 범위에 따라서 점수를 따로 측정하였다. easy 버전과 hard 버전이 있는 문제들이 많은데 그걸 한 문제로 합쳐놓은 것 같은 문제였다. 처음에 내가 제출한 코드는 이러했다. import sys input = sys.stdin.readline mod = 1000000007 N = int(input()) food = [*map(int,input().split())] food.sort() cal = {i:1 for i in range(N-1)} for i in range(1,N-1): cal[i] = cal[i-1]*2%mod result = 0 for i in range(N): for j in range(i+1,N): result += (food[j]-food.. [백준 13334번] 철로 (Python3) import sys input = sys.stdin.readline N = int(input()) info = [] for i in range(N): info.append(tuple(sorted(map(int,input().split())))) D = int(input()) home = [] com = [] for i in range(N): h,c = info[i] if c-h > D: continue home.append(h) com.append(c) home.sort() com.sort() N = len(home) cnt = result = 0 start = end = 0 while True: if start == N: break if start != 0: cnt -= 1 if h == home[st.. [백준 14725번] 개미굴 (Python3) import sys input = sys.stdin.readline N = int(input()) child = {0:set()} for _ in range(N): info = [*input().strip().split()] parent = 0 for i in range(1,len(info)): child[parent].add((info[i],i-1,parent)) parent = (info[i],i-1,parent) if child.get(parent): continue child[parent] = set() for i in child: child[i] = sorted(child[i]) def DFS(now): name,depth,_ = now print("--"*depth,end="") print(n.. [백준 20442번] ㅋㅋ루ㅋㅋ (Python3) import sys input = sys.stdin.readline seq = input().strip() l = len(seq) cntR = [] Rexist = 0 start,end = 0,l-1 while True: cntR.append(0) if start == end: if seq[start] == "R": Rexist = len(cntR) cntR[-1] += 1 break while seq[start] == "R": Rexist = len(cntR) cntR[-1] += 1 if start == end: break start += 1 if start == end: break while seq[end] == "R": Rexist = len(cntR) cntR[-1] += 1 end -= 1 i.. [백준 2533번] 사회망 서비스(SNS) (Python3) import sys input = sys.stdin.readline from collections import deque N = int(input()) graph = [[] for i in range(N)] nodes = [0]*N for i in range(N-1): x,y = map(int,input().split()) graph[x-1].append(y-1) graph[y-1].append(x-1) nodes[x-1] += 1 nodes[y-1] += 1 offlist = deque() onlist = deque() check = [0]*N for i in range(N): if nodes[i] == 1: offlist.append(i) result = 0 cnt = 0 while True: if .. 드디어 백준 플래티넘 달성! 드디어 플래티넘을 달성하였다. 작년 12월 5일에 처음 백준을 시작했으니, 대략 5주~6주 정도가 걸린 셈이다. 한달 전만 해도 Hello World도 못 풀던 내가 이렇게 성장하다니 감개무량하다.... 다이아를 향해서 열심히 달려봐야겠다. 화이팅! [백준 11003번] 최솟값 찾기 (Python3) from heapq import * N,L = map(int,input().split()) seq = [*map(int,input().split())] hq = [] minlist = [0]*N for i in range(N): heappush(hq,(seq[i],i)) while hq[0][1] [백준 5719번] 거의 최단 경로 (Python3) import sys input = sys.stdin.readline from heapq import heappush, heappop from collections import deque INF = 10**9 def Djikstra(): DP = [INF]*N hq = [] hq.append((0,start,start)) while hq: w,now,last = heappop(hq) if DP[now] < w: continue if DP[now] == w: path[now].append(last) continue DP[now] = w path[now] = [last] for next in range(N): w1 = graph[now][next] if w1 != INF: hq.append((w+w1,next.. 이전 1 ··· 38 39 40 41 42 43 44 ··· 51 다음 목록 더보기