Dev/Algorithm
소프티어 성적 평균
rryu09
2024. 11. 1. 11:49
처음 보는 플랫폼이다
import sys
input = sys.stdin.readline
n, k = map(int, input().split())
s = list(map(int, input().split()))
for i in range(1, n):
s[i] += s[i-1]
for _ in range(k):
a, b = map(int, input().split())
a-=1
b-=1
c=0
if a-1 >=0:
c = s[a-1]
print (round((s[b]-c)/(b-a+1),2))
간단하게 누적합으로 풀었다