백준

    그대, 그머가 되어 - 14496번

    그대, 그머가 되어 - 14496번

    내 코드 package com.company; import java.io.*; import java.util.*; public class Main { static int a, b, N, M; static int count = 0; static boolean[] visited; static ArrayList list = new ArrayList(); public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); a = Integer..

    악덕 영주 혜유

    악덕 영주 혜유

    풀이 방법 MST를 이용해서 모든 마을을 연결할 수 있는 최소 비용을 구해주었다. 그 경로 중 마을과 마을을 이동할 때 최악의 비용이 얼마인지 구해주기 위해 MST를 저장해주었다. 최악의 비용을 구하기 위해서는 임의의 한곳에서 dfs로 가장 먼 노드를 찾아주고 그 노드를 시작으로 dfs를 하면 나오게 된다. 내 코드 package com.company; import java.io.*; import java.util.*; public class Main { static int K, N, max, start; static int[][] arr; static int[][] arr2; static boolean[] visited; static Queue pq = new PriorityQueue(); public..

    플로이드 - 11404번

    플로이드 - 11404번

    내 코드 package com.company; import java.io.*; import java.util.*; public class Main { static int M, N; static int[][] arr; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); N = Integer.parseInt(br.readLine()); M = Integer.parseInt(br.readLine()); arr = new int[N + 1][N + 1]; StringTokenizer st = null; for (int i = ..

    쉬운 계단 수 - 10844번

    쉬운 계단 수 - 10844번

    내 코드 package com.company; import java.io.*; import java.util.*; public class Main { static int N; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); N = Integer.parseInt(br.readLine()); int[][] arr = new int[101][10]; for (int i = 1; i < 10; i++) { arr[1][i] = 1; } for (int i = 1; i < N; i++) { arr[i + 1][0] = arr..

    최소 힙 - 1927번

    최소 힙 - 1927번

    내 코드 package com.company; import java.io.*; import java.util.*; public class Main { static int N; static PriorityQueue pq = new PriorityQueue(); public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); N = Integer.parseInt(br.readLine()); int x = 0; for (int i = 0; i < N; i++) { x = Integer.parseInt(br.readLine()); if (..

    0만들기 - 7490번

    0만들기 - 7490번

    풀이 방법 DFS를 이용해서 모두 탐색 후 결과가 0으로 만족되면 list에 저장 list를 정렬 후 출력해줘야함 내 코드 package com.company; import java.io.*; import java.util.*; public class Main { static int K, N; static ArrayList list = new ArrayList(); public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); K = Integer.parseInt(br.readLine()); for (int i = 0; i < K..

    카드 섞기 -21315번

    카드 섞기 -21315번

    내 코드 package com.company; import java.io.*; import java.util.*; public class Main { static int N; static int[] arr; static LinkedList ll = new LinkedList(); public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); N = Integer.parseInt(br.readLine()); arr = new int[N]; StringTokenizer st = new StringTokenizer(br.readLine..

    트리 순회

    트리 순회

    내 코드 package com.company; import java.io.*; import java.util.*; public class Main { static int N; static int[][] arr; static Map map = new HashMap(); public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = null; N = Integer.parseInt(br.readLine()); for (int i = 0; i < N; i++) { st = new StringToken..

    신입 사원 - 1946번

    신입 사원 - 1946번

    내 코드 package com.company; import java.io.*; import java.util.*; public class Main { static int T, N; static int[][] arr; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = null; T = Integer.parseInt(br.readLine()); for (int i = 0; i < T; i++) { N = Integer.parseInt(br.readLine()); arr = new in..

    암호코드 - 2011번

    암호코드 - 2011번

    내 코드 package com.company; import java.io.*; import java.util.Arrays; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] s = br.readLine().split(""); int len = s.length; int[] dp = new int[len + 1]; int[] arr = new int[len + 1]; for (int i = 1; i