본문 바로가기

분류 전체보기

(257)
파이선) KCPC - BOJ https://www.acmicpc.net/problem/3758 3758번: KCPC 입력 데이터는 표준 입력을 사용한다. 입력은 T개의 테스트 데이터로 구성된다. 입력의 첫 번째 줄에는 테스트 데이터의 수를 나타내는 정수 T가 주어진다. 각 테스트 데이터의 첫 번째 줄에는 www.acmicpc.net T = int(input()) for i in range(T): # 팀의 수, 문제의 수, 내 팀 아이, 로엔트리 n, k, t, m = map(int, input().split()) dic = {} for idx in range(m): # 팀의 아이디. 문제번호, 점수 i, j, s = map(int, input().split()) if i not in dic: # 딕셔너리 저장 # 0번째는 점수 배열..
파이썬) 햄버거 분배 - BOJ https://www.acmicpc.net/problem/19941 19941번: 햄버거 분배 기다란 벤치 모양의 식탁에 사람들과 햄버거가 아래와 같이 단위 간격으로 놓여 있다. 사람들은 자신의 위치에서 거리가 $K$ 이하인 햄버거를 먹을 수 있다. 햄버거 사람 햄버거 사람 햄버거 사 www.acmicpc.net from collections import deque import sys input = sys.stdin.readline n, k = map(int, input().split()) a = input() arr = list(a.strip()) stack = [] pq = deque() hq = deque() cnt = 0 for i in range(len(arr)): if arr[i] == 'H'..
파이선) 수 이어 쓰기 - BOJ https://www.acmicpc.net/problem/1515 n = input() i = 0 while True: i += 1 num = str(i) while len(num) > 0 and len(n) > 0: if num[0] == n[0]: print('if', num, n) n = n[1:] num = num[1:] if n == '': print(i) break
파이썬) 블로그 - BOJ https://www.acmicpc.net/problem/21921 21921번: 블로그 첫째 줄에 $X$일 동안 가장 많이 들어온 방문자 수를 출력한다. 만약 최대 방문자 수가 0명이라면 SAD를 출력한다. 만약 최대 방문자 수가 0명이 아닌 경우 둘째 줄에 기간이 몇 개 있는지 출력한다 www.acmicpc.net n, x = map(int, input().split()) arr = list(map(int, input().split())) left = 0 right = x max_sum = sum(arr[left:right]) left += 1 right += 1 prev_range = max_sum cnt = 1 while right max_sum: cnt = 1 max_sum = this_rang..
리액트) 디스코드 클론 - 6 이번에는 스트리밍을 만들어 볼 예정이다 우선 스트리밍 또한 화상통화와 마찬가지로 navigator.mediaDevices 로 가져온다. 다만 useMedia를 가져오는 화상통화와 달리 스트리밍은 유저의 화면을 보여주는 것이므로 getDisplayMedia를 사용하면 된다. 같은 Room.js의 JSX에 해당 코드를 추가하자 SharingStart Stop sharing 그리고 아래 코드도 추가하자 const onSharingStart = async () => { try { await navigator.mediaDevices //유저의 화면들을 가져옴 .getDisplayMedia(displayMediaOptions) .then((stream) => { //비디오 태그에 송출 streamingVideoRe..
파이썬) 영단어 암기는 괴로워 - BOJ https://www.acmicpc.net/problem/20920 import sys input = sys.stdin.readline dic = {} n, m = map(int, input().split()) for i in range(n): s = input().rstrip() if len(s) >= m: if s not in dic: dic[s] = 1 else: dic[s] += 1 arr = sorted(dic.items(), key=lambda x: (-x[1], -len(x[0]), x[0])) for i in arr: print(i[0]) 이 문제는 주어진 조건만 달성하면 무난하게 풀 수 있는 문제이다. 먼저 딕셔너리에 영단어와 그 개수를 넣는다. 넣을 때 영단어의 길이를 확인한다. 그 다..
파이썬) 어두운 굴다리 -BOJ https://www.acmicpc.net/problem/17266 17266번: 어두운 굴다리 인하대학교 후문 뒤쪽에는 어두운 굴다리가 있다. 겁쟁이 상빈이는 길이 조금이라도 어둡다면 가지 않는다. 따라서 굴다리로 가면 최단거리로 집까지 갈수 있지만, 굴다리는 어둡기 때문에 빙 www.acmicpc.net import sys input = sys.stdin.readline n = int(input()) m = int(input()) position = list(map(int, input().split())) answer = 0 if len(position) == 1: answer = max(position - 0, n - position) else: for i in range(len(position))..
파이썬) 진우의 달 여행 (Small) - BOJ https://www.acmicpc.net/problem/17484 import sys input = sys.stdin.readline n, m = map(int, input().split()) arr = [] for i in range(n): arr.append(list(map(int, input().split()))) fuel = 1010101010101010 dy = [0, -1, 1] def dfs(x, y, p_y, fff, sums_fuel): if x == n-1: # 달에 도착했으면 현재까지의 연료 합과 여태 계산한 연료합 중 최소값 리턴 return min(sums_fuel, fff) for i in range(3): # 방향 설정 if dy[i] == p_y: # 이전에 갔었던 위치라면..