diff --git "a/lkhyun/202503/19 BOJ \352\263\250\353\223\2341 \354\265\234\354\206\237\352\260\222.md" "b/lkhyun/202503/19 BOJ \352\263\250\353\223\2341 \354\265\234\354\206\237\352\260\222.md" new file mode 100644 index 00000000..a42e65a3 --- /dev/null +++ "b/lkhyun/202503/19 BOJ \352\263\250\353\223\2341 \354\265\234\354\206\237\352\260\222.md" @@ -0,0 +1,62 @@ +```java +import java.util.*; +import java.io.*; + +class Node{ + long min; + long max; + Node(long min,long max){ + this.min = min; + this.max = max; + } +} +public class Main { + static int N; + static int M; + static long[] arr; + static Node[] 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()); + arr = new long[N*4]; + tree = new Node[N*4]; + + for(int i=1;i<=N;i++){ + arr[i] = Long.parseLong(br.readLine()); + } + init(1,1,N); + for(int i=0;iend || right=end) return tree[cur]; + + Node l = query(cur*2,start,(start+end)/2,left,right); + Node r = query(cur*2+1,(start+end)/2 + 1, end,left,right); + if(l==null)return r; + else if(r==null) return l; + else return new Node(Math.min(l.min,r.min),Math.max(l.max,r.max)); + } +} +```