BOJ24 [백준] 자바 문제 풀이 2696 : 골드2 BOJ 2696 : 중앙값 구하기 풀이 코드 import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.PriorityQueue; import java.util.Queue; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws Exception { // TODO Auto-generated method stub BufferedReader br = new B.. 2023. 10. 4. [백준] 자바 문제 풀이 2357 : 골드1 BOJ 2357 : 최솟값과 최댓값 풀이 코드 import java.io.*; import java.util.*; public class Main { static class SegmentTree{ private long[] max_tree; private long[] min_tree; SegmentTree(int n){ double treeHeight = Math.ceil(Math.log(n)/Math.log(2))+1; long treeNodeCount = Math.round(Math.pow(2, treeHeight)); max_tree = new long[Math.toIntExact(treeNodeCount)]; min_tree = new long[Math.toIntExact(treeNodeCount.. 2023. 10. 4. [백준] 자바 문제 풀이 2042 : 골드1 BOJ 2042 : 구간 합 구하기 풀이 코드 import java.io.*; import java.util.*; public class Main { static class SegmentTree { private long[] tree; SegmentTree(int n){ double height = Math.ceil(Math.log(n)/Math.log(2))+1; long size = Math.round(Math.pow(2, height)); tree = new long[Math.toIntExact(size)]; } long init(long[] arr, int node, int start, int end) { if(start == end) return tree[node] = arr[start]; re.. 2023. 10. 4. [백준] 자바 문제 풀이 1781 : 골드2 BOJ 1781 : 컵라면 풀이 코드 import java.io.*; import java.util.*; public class Main { static class Problem { int ramen; int time; Problem(int time, int ramen) { this.ramen = ramen; this.time = time; } } public static void main(String[] args) throws Exception { // TODO Auto-generated method stub BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWri.. 2023. 10. 4. [백준] 자바 문제 풀이 1253 : 골드4 BOJ 1253 : 좋다 풀이 코드 import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); int n = Integer.parseInt(br.readLine()); int[] arr = new int[n]; StringTokenizer str = new StringTokenizer(br.rea.. 2023. 9. 26. [백준] 자바 문제 풀이 1275 : 골드1 BOJ 1275 : 커피숍2 풀이 코드 import java.util.*; import java.io.*; public class Main { static class SegmentTree { public long[] tree; SegmentTree(int n){ double height = Math.ceil(Math.log(n)/Math.log(2)) + 1; long node = Math.round(Math.pow(2, height)); tree = new long[Math.toIntExact(node)]; } long init(long[] arr, int node, int start, int end) { if(start == end) { return tree[node] = arr[start]; } e.. 2023. 9. 26. [백준] 자바 문제 풀이 5676 : 골드1 BOJ 5676 : 음주코딩 import java.util.*; import java.io.*; public class Main { static class SegmentTree { public long[] st; SegmentTree(int n){ double height = Math.ceil(Math.log(n)/Math.log(2))+1; long node = Math.round(Math.pow(2, height)); st = new long[Math.toIntExact(node)]; } long init(long[] arr, int node, int start, int end) { if(start == end) { return st[node] = (arr[start] > 0) ? 1 : (arr[s.. 2023. 9. 26. [백준] 자바 문제 풀이 1655 : 골드2 BOJ 1655 풀이 코드 import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); int n = Integer.parseInt(br.readLine()); PriorityQueue maxq = new PriorityQueue((o1, o2) -> (o2 - o1)); PriorityQueue.. 2023. 9. 23. [백준] 자바 문제 풀이 10868 : 골드1 BOJ 10868 풀이 코드 import java.io.*; import java.util.*; public class Main { static class SegmentTree{ private long[] tree; SegmentTree(int n){ double height = Math.ceil(Math.log(n)/Math.log(2))+1; long size = Math.round(Math.pow(2, height)); tree = new long[Math.toIntExact(size)]; } long init(long[] arr, int node, int start, int end) { if(start == end) return tree[node] = arr[start]; return tree[n.. 2023. 9. 23. [백준] 자바 문제 풀이 17822 : 골드2 BOJ 17822 풀이 코드 import java.io.*; import java.util.*; public class Main { static class Point { int a; int b; Point(int a, int b) { this.a = a; this.b = b; } } public static void main(String[] args) throws Exception { // TODO Auto-generated method stub BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out.. 2023. 9. 22. [백준] 자바 문제 풀이 1715 : 골드4 BOJ 1715 풀이 코드 import java.io.*; import java.util.PriorityQueue; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws Exception { BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); PriorityQueue pq = new Priorit.. 2023. 9. 22. [백준] 자바 문제 풀이 12837 : 골드1 BOJ 12837 풀이 코드 import java.io.*; import java.util.*; public class Main { static class SegmentTree { private long[] tree; SegmentTree(int n) { double treeHeight = Math.ceil(Math.log(n)/Math.log(2))+1; long treeNodeCount = Math.round(Math.pow(2, treeHeight)); tree = new long[Math.toIntExact(treeNodeCount)]; } long init(long[] arr, int node, int start, int end) { if(start == end) { return tree[nod.. 2023. 9. 22. 이전 1 2 다음 728x90 반응형