From a808c02e4b7e3e2922b7669d1c49e14c1f9de9e5 Mon Sep 17 00:00:00 2001 From: lkhyun <102892446+lkhyun@users.noreply.github.com> Date: Wed, 19 Mar 2025 17:37:12 +0900 Subject: [PATCH] =?UTF-8?q?[20250319]=20BOJ=20/=20=EA=B3=A8=EB=93=9C1=20/?= =?UTF-8?q?=20=EA=B0=80=EA=B3=84=EB=B6=80=20/=20=EC=9D=B4=EA=B0=95?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...1 \352\260\200\352\263\204\353\266\200.md" | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 "lkhyun/202503/19 BOJ \352\263\250\353\223\2341 \352\260\200\352\263\204\353\266\200.md" diff --git "a/lkhyun/202503/19 BOJ \352\263\250\353\223\2341 \352\260\200\352\263\204\353\266\200.md" "b/lkhyun/202503/19 BOJ \352\263\250\353\223\2341 \352\260\200\352\263\204\353\266\200.md" new file mode 100644 index 00000000..63c0ab63 --- /dev/null +++ "b/lkhyun/202503/19 BOJ \352\263\250\353\223\2341 \352\260\200\352\263\204\353\266\200.md" @@ -0,0 +1,46 @@ +```java +import java.util.*; +import java.io.*; + +public class Main { + static int N; + static int Q; + 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()); + Q = Integer.parseInt(st.nextToken()); + tree = new long[N*4]; + for(int i=0;iend) return; + tree[cur] += diff; + if(start != end){ + update(cur*2,start,(start+end)/2,idx,diff); + update(cur*2 + 1,(start+end)/2 + 1,end,idx,diff); + } + } + public static long query(int cur, int start, int end, int left, int right){ + if(left>end || right=end) return tree[cur]; + + long l = query(cur*2,start,(start+end)/2,left,right); + long r = query(cur*2+1,(start+end)/2 + 1, end,left,right); + return l+r; + } +} +```