[c++] 2042 구간 합 구하기 (세그먼트 트리)
세그먼트 트리 이해 https://www.acmicpc.net/blog/view/9 세그먼트 트리 (Segment Tree) 문제 배열 A가 있고, 여기서 다음과 같은 두 연산을 수행해야하는 문제를 생각해봅시다. 구간 l, r (l ≤ r)이 주어졌을 때, A[l] + A[l+1] + ... + A[r-1] + A[r]을 구해서 출력하기 i번째 수를 v로 바꾸기. A[i www.acmicpc.net 전체 코드 #include #include #include #include using namespace std; typedef long long ll; ll N, M, K, input, a, b, c; ll init(vector &arr, vector &tree, ll node, ll start, ll end..