
알고리즘/백준
[11659] 구간 합 구하기 4 (Python)
문제 11659번: 구간 합 구하기 4 첫째 줄에 수의 개수 N과 합을 구해야 하는 횟수 M이 주어진다. 둘째 줄에는 N개의 수가 주어진다. 수는 1,000보다 작거나 같은 자연수이다. 셋째 줄부터 M개의 줄에는 합을 구해야 하는 구간 i와 j www.acmicpc.net 틀린 코드 N,M = map(int,input().split()) num_list = [-1]+list(map(int,input().split())) for _ in range(M): start_index,end_index = map(int,input().split()) print(sum(num_list[start_index:end_index+1])) 문제 풀이 처음 이 문제를 단순 구현으로 생각해서 시간초과가 났었습니다. 정수 범위를..