diff --git "a/lkhyun/202503/19 BOJ \352\263\250\353\223\2341 \352\265\254\352\260\204\355\225\251 \352\265\254\355\225\230\352\270\260.md" "b/lkhyun/202503/19 BOJ \352\263\250\353\223\2341 \352\265\254\352\260\204\355\225\251 \352\265\254\355\225\230\352\270\260.md" new file mode 100644 index 00000000..0988391b --- /dev/null +++ "b/lkhyun/202503/19 BOJ \352\263\250\353\223\2341 \352\265\254\352\260\204\355\225\251 \352\265\254\355\225\230\352\270\260.md" @@ -0,0 +1,68 @@ +```java +import java.util.*; +import java.io.*; + +public class Main { + static int N; + static int M; + static int K; + static long[] arr; + static long[] tree; + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + K = Integer.parseInt(st.nextToken()); + arr = new long[N*4]; + tree = new long[N*4]; + + for(int i=1;i<=N;i++){ + arr[i] = Long.parseLong(br.readLine()); + } + init(1,1,N); + for(int i=0;iend){//구하려는 구간내에 현재 범위가 없어. + return 0; + }else if(left<=start && right>=end){//구하려는 구간내에 현재 범위가 있어. 다 더해야겟지 + return tree[num]; + } + long lsum = query(num*2, start, (start+end)/2, left, right); + long rsum = query(num*2+1, (start+end)/2 + 1, end, left, right); + return lsum + rsum; + } + public static void update(int num, int start, int end, int index, long diff){// 수정 + if(start>index || end