[c++] K번째수
programmers.co.kr/learn/courses/30/lessons/42748 코딩테스트 연습 - K번째수 [1, 5, 2, 6, 3, 7, 4] [[2, 5, 3], [4, 4, 1], [1, 7, 3]] [5, 6, 3] programmers.co.kr #include #include #include using namespace std; vector solution(vector array, vector commands) { vector answer; for (int n=0; n
[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..