백준_1929 소수 구하기 (에라토스테네스의 채)
Algorithm/Algorithm 문제2024. 2. 1. 11:19백준_1929 소수 구하기 (에라토스테네스의 채)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class BJ_1929_소수구하기 { public static void main(String[] args) throws IOException { int i, j; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine(), " "); int m = Integer.parseInt(st.nextToke..

백준_1541 잃어버린 괄호 (그리디)
Algorithm/Algorithm 문제2024. 1. 31. 10:21백준_1541 잃어버린 괄호 (그리디)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class BJ_1541_잃어버린괄호 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine(), "-"); int firstNum = calculate(st.nextToken()); int..

백준_1931 회의실 배정 (그리디)
Algorithm/Algorithm 문제2024. 1. 30. 14:05백준_1931 회의실 배정 (그리디)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Comparator; import java.util.PriorityQueue; import java.util.Queue; import java.util.StringTokenizer; public class BJ_1931_회의실배정 { public static void main(String[] args) throws IOException { StringTokenizer st; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int..

백준_1744 수 묶기 (그리디)
Algorithm/Algorithm 문제2024. 1. 29. 14:19백준_1744 수 묶기 (그리디)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Comparator; import java.util.PriorityQueue; import java.util.Queue; public class BJ_1744_수묶기 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); Queue queueP; // 양..

백준_1715 카드 정렬하기 (그리디)
Algorithm/Algorithm 문제2024. 1. 28. 16:58백준_1715 카드 정렬하기 (그리디)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.PriorityQueue; import java.util.Queue; public class BJ_1715_카드정렬하기 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); Queue priorityQ = new PriorityQueue(); //기본은..

백준_11047 동전0 (그리디)
Algorithm/Algorithm 문제2024. 1. 27. 16:40백준_11047 동전0 (그리디)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class BJ_11047_동전0 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine(), " "); int n = Integer.parseInt(st.nextToken()); int k..

백준_1300 K번째 수 (이분탐색)
Algorithm/Algorithm 문제2024. 1. 26. 13:10백준_1300 K번째 수 (이분탐색)

이분탐색을 떠올리기도 힘들고 다른 사람의 풀이를 봐도 많이 어려워서 이해하고 받아들이는데 3시간이 걸린 문제 빨간 부분의 증명은 아직도 명쾌히 내리지 못했다. 참고) https://st-lab.tistory.com/281 추가로 주의할 점은 cnt와 k를 비교하며 탐색범위를 줄일 때 자칫하다가는 cnt == k 일때 정답이겠거니 하고 break를 걸려 m을 출력할 수 있다. 나도 그렇게 생각하고 했다가 계속 틀려서 왜 그런지 생각하느라 애먹었다. cnt==k여도, 탐색 범위의 중앙값 m이 본 문제에서 주어지는 행렬에 존재하지 않는 값일 수가 있기 때문! 그렇다면 위의 코드대로 하면 행렬에 존재하는 적절한 값으로 수렴하느냐..? 어차피 작거나 같은 개수를 비교하는 기준인 b[k]는 문제에 존재하는 값이다...

백준_2343 기타 레슨 (이분탐색)
Algorithm/Algorithm 문제2024. 1. 25. 12:30백준_2343 기타 레슨 (이분탐색)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class BJ_2343_기타레슨 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine(), " "); int n, m, i, s, e, mid; n = Integer.parseInt(st..

백준_1920 수 찾기 (이분탐색)
Algorithm/Algorithm 문제2024. 1. 24. 20:03백준_1920 수 찾기 (이분탐색)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class BJ_1920_수찾기 { static int[] arr; static StringBuilder sb; public static void main(String[] args) throws IOException { int n, m, i; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); sb = new StringBuilder(); n =..

image