본문 바로가기

코딩테스트13

17389 보너스 점수, 16165 걸그룹 마스터 준석이, 17224 APC는 왜 서브태스크 대회가 되었을까? 17389 보너스 점수, 16165 걸그룹 마스터 준석이, 17224 APC는 왜 서브태스크 대회가 되었을까? 17389 보너스 점수 # 첫번째 풀이(consol, VSC에서 되는데 백죽에서 런타임 에러.. 이유 모르겠음) N, S = int(input()), input() score, bouns = 0, 0 for i in range(N): if S[i] == 'O': score, bonus = score + i + bonus + 1, bonus + 1 else: bonus = 0 print(score) # 두번째 풀이 N, S = input(), input() score, bonus = 0, 0 for idx, OX in enumerate(S): if OX == 'O': score, bonus = s.. 2020. 10. 21.
15969 행복, 10539 수빈이와 수열, 17269 이름궁합 테스트 15969 행복, 10539 수빈이와 수열, 17269 이름궁합 테스트 15969 행복 n, array = int(input()), list(map(int, input().split())) print(max(array) - min(array)) 10539 수빈이와 수열 # 첫번째 풀이 n, array = int(input()), list(map(int, input().split())) A = [] A.append(array[0]) for i in range(1, n): A.append(array[i] * (i+1) - sum(A)) for i in range(n): if i == n-1: print(A[i]) else: print(A[i], end=' ') n, array = int(input()), l.. 2020. 10. 20.
1781 컵라면, 9663 N-Queen, 1987 알파벳 1781 컵라면, 9663 N-Queen, 1987 알파벳 1781 컵라면 import heapq n = int(input()) array = [] q = [] for _ in range(n): # take deadline, number of noodle and sorting x, y = map(int, input().split()) array.append((x, y)) array.sort() for i in array: # add noodles and if deadline over, delete minimum value in list a = i[0] heapq.heappush(q, i[1]) if a < len(q): heapq.heappop(q) print(sum(q)) - 두 원소 받아서 튜플로 정.. 2020. 10. 14.
5585 거스름돈, 1439 뒤집기, 2012 등수 매기기 5585 거스름돈, 1439 뒤집기, 2012 등수 매기기 5585 거스름돈 # 첫번째 풀이 money_list = [500, 100, 50, 10, 5, 1] money = int(input()) money = 1000 - money count = 0 for i in money_list: if money < i: continue else: count += money // i money = money % i print(count) # 두번째 풀이(더 간단하게) money = 1000 - int(input()) count = 0 for i in [500, 100, 50, 10, 5, 1]: count += money // i money %= i print(count) 1439 뒤집기 s = input() .. 2020. 10. 12.