본문 바로가기

전체 글

(275)
백준 14502 : 연구소 [JAVA] [문제 링크]https://www.acmicpc.net/problem/14502[난이도]- Gold 4 [알고리즘]- BFS- 백트래킹 [코드]import java.io.*;import java.util.*;public class Main { static int N, M, result = 0; static int[][] map; static int[] dx = {-1, 1, 0, 0}; static int[] dy = {0, 0, -1, 1}; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(Syst..
백준 1931: 회의실배정 [JAVA] [문제 링크]https://www.acmicpc.net/problem/1931[난이도]- Silver 1 [알고리즘]- 그리디 [코드]import java.io.*;import java.util.*;public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine()); int[][] meetings = new int[N][2]; for (int i = 0; i { ..
백준 1446 : 지름길 [JAVA] [문제 링크]https://www.acmicpc.net/problem/1446[난이도]- Silver 1 [알고리즘]- DP- 다익스트라 [코드]import java.util.*;public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int N = scanner.nextInt(); // 지름길의 개수 int D = scanner.nextInt(); // 고속도로의 길이 // graph를 생성하고 초기화 List> graph = new ArrayList(); for (int i = 0; i ()); ..
백준 2156 : 포도주 시식 [JAVA] [문제 링크]https://www.acmicpc.net/problem/2156[난이도]- Silver 1 [알고리즘]- DP [코드]import java.io.BufferedReader;import java.io.InputStreamReader;import java.io.IOException;public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int[] wine = ne..
백준 2529 : 부등호 [JAVA] [문제 링크]https://www.acmicpc.net/problem/2529[난이도]- Silver 1 [알고리즘]- 백트래킹 [코드]import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.ArrayList;import java.util.List;public class Main { static int k; static char[] operators; static boolean[] visited = new boolean[10]; static List results = new ArrayList(); public static void main(St..
백준 2023 : 신기한 소수 [JAVA] [문제 링크]https://www.acmicpc.net/problem/2023[난이도]- Gold 5 [알고리즘]- 백트래킹 [코드]import java.io.*;import java.util.*;public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine()); // 초기 신기한 소수 시작 자리 설정 int[] primeStarts = {2, 3, 5, 7}; ..
백준 13023 : ABCDE [JAVA] [문제 링크]https://www.acmicpc.net/problem/13023[난이도]- Gold 5 [알고리즘]- 백트래킹 [코드]import java.io.BufferedReader;import java.io.InputStreamReader;import java.io.IOException;import java.util.ArrayList;import java.util.StringTokenizer;public class Main { static int N, M; static ArrayList> adj; static boolean[] visited; static boolean found = false; public static void main(String[] args) thr..
백준 2573 : 빙산 [JAVA] [문제 링크]https://www.acmicpc.net/problem/2573[난이도]- Gold 4 [알고리즘]- BFS [코드]import java.io.*;import java.util.*;public class Main { static int N, M; static int[][] map; static boolean[][] visited; static int[] dx = {-1, 1, 0, 0}; static int[] dy = {0, 0, -1, 1}; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStrea..