하기싫다..해야한다..하기싫다..해야한다..해야해!!!
큐를 사용하면 간단하게 해결 가능!
from collections import deque
N = int(input())
deque = deque([i for i in range(1, N+1)])
while(len(deque) >1):
deque.popleft()
move_num = deque.popleft()
deque.append(move_num)
print(deque[0])
N, K = map(int, input().split())
coins=[]
for i in range(N):
coins.append(int(input()))
coins.sort(reverse=True)
result=0
for i in coins:
if K==0:
break
result += K//i
K %= i
print(result)
import sys
n = int(sys.stdin.readline())
lst = []
for i in range(n):
lst.append(sys.stdin.readline().strip())
set_lst = set(lst)
lst = list(set_lst)
lst.sort()
lst.sort(key = len)
for i in lst:
print(i)
import sys
n=int(sys.stdin.readline())
li=[]
for i in range(n):
a, b = map(int, sys.stdin.readline().split())
li.append([a, b])
li.sort()
for i in li:
print(i[0], i[1])
- 구간 합 구하기 4
https://www.acmicpc.net/problem/11659
import sys
input = sys.stdin.readline
m, n = map(int, input().split())
arr = list(map(int, input().split()))
prefix_sum = [0] # init prefix_sum
temp = 0
for i in arr: # accumulate arr section
temp += i
prefix_sum.append(temp)
for i in range(n):
a, b = map(int, input().split())
print(prefix_sum[b] - prefix_sum[a-1])