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