-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
16-SeongHoonC #60
16-SeongHoonC #60
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ μ΄ λ¬Έμ μ€λλ§μ΄λ€μ γ γ γ γ γ
λκ°μ λ‘μ§μΌλ‘ νμλ λ¬Έμ μ λλ€!
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
lst = list((map(int, input().split())))
sums = [0] * (N+1)
for i in range(N):
sums[i+1] = sums[i] + lst[i]
for _ in range(M):
i, j = map(int, input().split())
print(sums[j] - sums[i-1])
ν μ λ νμλμ΄λ λΉμ·ν μ½λλ‘ μμ±λλλ° tempλ§ μΆκ°λμ νλ€μ!! import sys
input = sys.stdin.readline
m, n = map(int, input().split())
arr = list(map(int, input().split()))
answer = [0]
temp = 0
for i in arr:
temp += i
answer.append(temp)
# print(answer)
for i in range(n):
a, b = map(int, input().split())
print(answer[b] - answer[a-1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ²μμ λ¬Έμ μμ μ½κ΅° μ΄λ¬λ€κ° μκ°μ΄κ³Ό λ¨κ³ λΉν©... νμ λ€λ₯Έ λΆλ€ μ½λλ³΄κ³ λ¨Έλ¦¬κ° λ΅νλ€μ γ
γ
γ
λμ ν© κ°λ
μΌλ‘ ν μ λ°°μλλ€!
import sys
input = sys.stdin.readline
N,M = map(int, input().split())
num_list = list(map(int, input().split()))
accumulate_list = [0] * (N+1)
for i in range(N):
accumulate_list[i+1] = accumulate_list[i] + num_list[i]
for _ in range(M):
start, end = map(int, input().split())
print(accumulate_list[end] - accumulate_list[start-1])
π λ¬Έμ λ§ν¬
κ΅¬κ° ν© κ΅¬νκΈ° 4
βοΈ μμλ μκ°
40λΆ
β¨ μλ μ½λ
첫λ²μ§Έ μλ
리μ€νΈλ₯Ό μλΌμ μ΄ν© ꡬνλλ λΉμ°ν μκ°μ΄κ³Όκ° λ°μνμ΅λλ€.
μ΅λ 100000(N) * 100000(M) λ² μ°μ°μ΄ μ€νλ μ μκΈ° λλ¬Έμ΄μμ£
λͺ»νκ² λ€ μΆμ΄μ μ νμ λ΄€λλ° λμ ν©μ΄μμ΅λλ€.
μ.. 5 λ²μ§ΈκΉμ§ λμ ν©μ 2 λ²μ§ΈκΉμ§ λμ ν©μ λΉΌλ©΄ 3~5 ꡬκ°ν©μ΄ λμ€λ κ²μ΄μμ΅λλ€.
μ΄λ¬λ©΄ N + M λ² μ°μ°μ μνν κ²μΌλ‘ μμλ©λλ€.
print λ μκ°μ΄ μ€λκ±Έλ¦°λ€κΈΈλ BufferedWriter μ write νκ³ νλ²μ flush νμ΅λλ€.
π μλ‘κ² μκ²λ λ΄μ©
λμ ν©μ μ΄ν΄νκ² λμλ€μ.
μλ©΄ μ¬μ΄λ° λͺ¨λ₯΄λ©΄ λ μ¬λ¦¬κΈ° μ΄λ €μ΄ λ¬Έμ κ°μμ 곡μ νμ΅λλ€.