본문 바로가기

알고리즘 문제 풀기/BOJ

BOJ 1120 - 문자열 https://www.acmicpc.net/problem/1120 BOJ 1120 - 문자열 작성언어: python3a, b = input().split()ans = 51cnt = 0​for i in range(0, len(b) - len(a) + 1): cnt = 0 for j in range(0, len(a)): if a[j] != b[j+i]: cnt += 1 ans = min(cnt, ans)​print(ans)pc 환경에서 코드를 보는 것을 권장합니다.
BOJ 2875 - 대회 or 인턴 https://www.acmicpc.net/problem/2875 BOJ 2875 - 대회 or 인턴 작성언어: Python3xxxxxxxxxxn, m, k = map(int, input().split())​print(int(min(min(n/2, m), (n+m-k)/3)))pc 환경에서 코드를 보는 것을 권장합니다.
BOJ 10610 - 30 https://www.acmicpc.net/problem/10610 BOJ 10610 - 30 작성언어: Python3n = input()number = []ans = ''​for item in n: number.append(item)​number.sort(reverse=True)​for item in number: ans += itemans = int(ans)​if ans % 10 == 0 and ans % 3 == 0: print(ans)else: print(-1)pc 환경에서 코드를 보는 것을 권장합니다.
BOJ 2217 - 로프 https://www.acmicpc.net/problem/2217 BOJ 2217 - 로프 작성언어: Python3n = int(input())ans = 0rope_list = []​for i in range(n): rope_list.append(int(input()))rope_list.sort()​for i in range(0, len(rope_list)): ans = max(ans, rope_list[i]*(n-i))​print(ans)pc 환경에서 코드를 보는 것을 권장합니다.
BOJ 5585 - 거스름돈 BOJ 5585 - 거스름돈 작성언어: Python3change = 1000 - int(input())kindsOfMoney = [500, 100, 50, 10, 5, 1]cnt = 0​while change != 0: for money in kindsOfMoney: if change // money > 0: cnt += change // money change = change % money​print(cnt)pc 환경에서 코드를 보는 것을 권장합니다.
BOJ 1541 - 잃어버린 괄호 https://www.acmicpc.net/problem/1541 BOJ 1541 - 잃어버린 괄호 작성언어: Python3exp = input().split('-')itemList = []​for t in exp: temp = list(map(int, t.split('+'))) itemList.append(sum(temp))​total = itemList[0]​for item in itemList[1:]: total -= item​print(total)pc 환경에서 코드를 보는 것을 권장합니다.
BOJ 11399 - ATM https://www.acmicpc.net/problem/11399 BOJ 11399 - ATM 작성언어: Python3n = int(input())time = list(map(int, input().split()))totalTime = 0cumulativeTime = 0​time.sort()​for t in time: cumulativeTime += t totalTime += cumulativeTime​print(totalTime)pc 환경에서 코드를 보는 것을 권장합니다.
BOJ 1931 - 회의실배정 https://www.acmicpc.net/problem/1931 BOJ 1931 - 회의실배정 작성언어: Python3xxxxxxxxxxn = int(input())conf = []​for i in range(n): conf.append(list(map(int, input().split())))conf.sort(key=lambda x : [x[1],x[0]])​cnt = 1j = 0​for i in range(1, len(conf)): if(conf[i][0] >= conf[j][1]): cnt += 1 j = i​print(cnt)pc 환경에서 코드를 보는 것을 권장합니다.