Algorithm89 [백준] 1357 뒤집힌 덧셈 변수를 거꾸로 하는 변수명[::-1]를 사용하면 쉬움 x, y = map(str, input().split()) print(int(str(int(x[::-1]) + int(y[::-1]))[::-1])) 2020. 11. 30. [백준] 1417번 국회의원 선거 쉬운 문제.. N = int(input()) if N == 1: print(0) else: votes = [] for i in range(N): votes.append(int(input())) pick = votes.pop(0) votes = sorted(votes, reverse=True) ans = 0 while True: if pick > max(votes): break votes[0] -= 1 pick += 1 votes = sorted(votes, reverse=True) ans += 1 print(ans) 2020. 11. 28. [백준] 2812번 크게 만들기 뭔가.. 되게 오래 걸릴꺼 같았는데 생각보다 금방 풀었다.. 뭔가 더 로직을 간편화 할 수 있을꺼같은데.. 나중에 해봐야지.. import sys length, delete = map(int, sys.stdin.readline().strip().split()) valNum = list(sys.stdin.readline().strip()) ans = [valNum[0]] for i in range(1, length): if len(ans) == length - delete: if i != length and delete == 0: ans.append(valNum[i:]) break while len(ans) > 0 and ans[-1] 0: ans.pop() d.. 2020. 11. 28. [백준] 2947번 나무조각 쉬운 문제.. def printList(L): for i in range(len(L)): print(L[i], end=" ") print() inputList = list(map(int, input().split())) sortedList = sorted(inputList) while inputList != sortedList: for i in range(len(inputList) - 1): if inputList[i] > inputList[i + 1]: temp = inputList[i + 1] inputList[i + 1] = inputList[i] inputList[i] = temp printList(inputList) 2020. 11. 27. 이전 1 ··· 4 5 6 7 8 9 10 ··· 23 다음