99ํด๋Ÿฝ

๋ฌธ์ œ๋ฐฑ์ค€ ๊ทธ๋ฆผ https://www.acmicpc.net/problem/1926 ์ฝ”๋“œfrom collections import dequen, m = map(int, input().split()) # ์„ธ๋กœ, ๊ฐ€๋กœpaper = [list(map(int, input().split())) for _ in range(n)]visit = [[False for _ in range(m)] for _ in range(n)] # ๋ฐฉ๋ฌธ ๊ธฐ๋ก์šฉmaxi = 0picture_count = 0for i in range(n): # ์„ธ๋กœ์ขŒํ‘œ for j in range(m): # ๊ฐ€๋กœ์ขŒํ‘œ if paper[i][j] == 1 and visit[i][j] == False: # ๊ทธ๋ฆผ์ด๊ณ , ๋ฐฉ๋ฌธํ•œ์  ์—†๋‹ค๋ฉด ..
๋ฌธ์ œ๋ฐฑ์ค€ ์•”ํ˜ธ ๋งŒ๋“ค๊ธฐ https://www.acmicpc.net/problem/1759 ์ฝ”๋“œl, c = map(int, input().split()) # ์•”ํ˜ธ๊ธธ์ด, ํ›„๋ณด ๋ฌธ์ž ๊ฐœ์ˆ˜letters = sorted(list(map(str, input().split()))) # ํ›„๋ณด ๋ฌธ์žarr = []# ๋ชจ์Œ ์„ธ๋Š” ํ•จ์ˆ˜def count_vowel(lst): return lst.count('a') + lst.count('e') + lst.count('i') + lst.count('o') + lst.count('u')def recur(idx): if len(arr) == l: # ๋ชจ์Œ ํ•œ๊ฐœ์ด์ƒ, ์ž์Œ ๋‘๊ฐœ ์ด์ƒ์ด๋ฉด if count_vowel(arr) >= 1 and l - c..
๋ฌธ์ œ๋ฐฑ์ค€ ๋ฆฌ๋ชจ์ปจ https://www.acmicpc.net/problem/1107 ์ฝ”๋“œtarget = int(input())m = int(input())if m != 0: broken = list(map(int, input().split()))else: broken = []count = abs(100 - target)for num in range(1000000 + 1): for n in str(num): if int(n) in broken: break else: count = min(count, len(str(num)) + abs(num - target))print(count) ํ’€์ดtarget = int(input())m = int(inp..
๋ฌธ์ œ๋ฐฑ์ค€ ๊ฐ์†Œํ•˜๋Š” ์ˆ˜ https://www.acmicpc.net/problem/1038 ์ฝ”๋“œn = int(input())if n > 1022: print(-1)else: num = [] ans = [] def check(i): global num if len(num) == 1: return True if num[-2] > i: return True def dfs(depth): global num for i in range(10): num.append(i) if check(i): dfs(depth + 1) ..
๋ฌธ์ œ ๋ฐฑ์ค€ ์ˆซ์ž์นด๋“œ 2https://www.acmicpc.net/problem/10816 ์ฝ”๋“œN = int(input())cards = sorted(list(map(int, input().split())))M = int(input())want_card = (list(map(int, input().split())))count = {}for card in cards: if card in count: count[card] += 1 else: count[card] = 1def binarySearch(arr, target, start, end): if start > end: return 0 mid = (start + end) // 2 if arr[m..
๋ฌธ์ œํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ž…๊ตญ์‹ฌ์‚ฌhttps://school.programmers.co.kr/learn/courses/30/lessons/43238 ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”.programmers.co.kr ์ฝ”๋“œdef solution(n, times): answer = 0 # s(start), e(end) ํˆฌํฌ์ธํ„ฐ! s = 1 e = max(times) * n while s = n: break #์—…? if check_person >= n: e = mid - 1 an..
๋ฌธ์ œํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ํƒ€๊ฒŸ ๋„˜๋ฒ„https://school.programmers.co.kr/learn/courses/30/lessons/43165 ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”.programmers.co.kr ์ฝ”๋“œanswer = 0def dfs(numbers, target, result, idx): global answer # ์ข…๋ฃŒ์กฐ๊ฑด if idx == len(numbers): if result == target: answer += 1 return else: return # ๋”..
๋ฌธ์ œํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์นดํŽซhttps://school.programmers.co.kr/learn/courses/30/lessons/42842 ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”.programmers.co.kr ์ฝ”๋“œdef solution(brown, yellow): for i in range(5000 + 1): # ์„ธ๋กœ๊ธธ์ด for j in range(5000 + 1): # ๊ฐ€๋กœ๊ธธ์ด if i * j == brown + yellow and i + j - 1 == brown//2 + 1: return [j, i] ํ’€์ด์™„์ „ํƒ..
๋ฌธ์ œํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ๊ฐ€์žฅ ํฐ ์ˆ˜https://school.programmers.co.kr/learn/courses/30/lessons/42746?language=python3 ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”.programmers.co.kr ์ฝ”๋“œimport itertoolsdef solution(numbers): numbers_per = list(itertools.permutations(numbers)) answer = -1 for i in range(len(numbers_per)): lst = list(numbers_per[i]) for ..
๋ฌธ์ œํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์˜ฌ๋ฐ”๋ฅธ ๊ด„ํ˜ธhttps://school.programmers.co.kr/learn/courses/30/lessons/12909/ ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”.programmers.co.kr  ์ฝ”๋“œdef solution(s): stack = [] for gwalho in s: if not stack: stack.append(gwalho) else: if gwalho == ')' and stack[-1] == '(': stack.pop() e..
๋ฌธ์ œํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ๊ธฐ๋Šฅ๊ฐœ๋ฐœhttps://school.programmers.co.kr/learn/courses/30/lessons/42586 ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”.programmers.co.kr ์ฝ”๋“œfrom collections import dequedef solution(progresses, speeds): progresses_que = deque(progresses) speeds_que = deque(speeds) answer = [] while progresses_que: while progresses_que[0] = 100: ..
๋ฌธ์ œํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์˜์ƒhttps://school.programmers.co.kr/learn/courses/30/lessons/42578 ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”.programmers.co.kr ํ‚ค์›Œ๋“œ๊ฐ€ ํ•ด์‹œ์ธ๋งŒํผ, ์ตœ๋Œ€ํ•œ ํ•ด์‹œ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ๋ฌธ์ œ๋ฅผ ํ’€์—ˆ๋‹ค. ์ฝ”๋“œdef solution(clothes): closet = {} for name, kind in clothes: if kind in closet.keys(): closet[kind] += [name] else: closet[kind] = [nam..
๋•ก๋•ก๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป
'99ํด๋Ÿฝ' ํƒœ๊ทธ์˜ ๊ธ€ ๋ชฉ๋ก (2 Page)