본문 바로가기
728x90

코딩 문제 풀이/백준44

[백준] 자바 문제 풀이 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.
[백준] 자바 문제 풀이 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.
[백준] 자바 문제 풀이 10775 : 골드2 BOJ 10775 풀이 코드 import java.io.*; import java.util.*; public class Main { static int[] gate; static int find(int p) { if(gate[p] == p) return p; gate[p] = find(gate[p]); return gate[p]; } public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); in.. 2023. 9. 23.
[백준] 자바 문제 풀이 11505 : 골드1 BOJ 11505 풀이 코드 import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.StringTokenizer; 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.. 2023. 9. 23.
[백준] 자바 문제 풀이 2109 : 골드3 BOJ 2109 풀이 코드 import java.io.*; import java.util.*; public class Main { static class Lecture { int cost; int day; Lecture(int cost, int day) { this.cost = cost; this.day = day; } } 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 Output.. 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.
728x90
반응형