Study & Project ✏️/알고리즘 📋 44

백준[Python] 10815.숫자 카드 - 파이썬

📖 문제 📃 코드 import sys n = int(input()) card = list(map(int, sys.stdin.readline().split())) m = int(input()) check = list(map(int, sys.stdin.readline().split())) card.sort() def binarySearch(array, key, start, end): while start key: end = mid-1 elif array[mid] < key: start = mid+1 return None for i in range(m): if binarySearch(card, check[i], 0, n-1) is not None: print(1, end=' ') else: print(0, e..

[알고리즘] 플로이드 와샬 알고리즘 - 자바

📖 문제 플로이드 와샬 알고리즘을 직접 만들어보시오 📃 코드 public class Main { static int INF = 1000000; public static void main(String[] args) { int[][] dp = { { 0, 8, 1, INF }, { INF, 0, INF, 1 }, { INF, 2, 0, 9 }, { 4, INF, INF, 0 } }; DP(dp); } private static void DP(int[][] dp) { // result array int result[][] = new int[4][4]; // init for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { result[i][j] = dp[i][..

백준[JAVA] 11279.최대 힙 - 자바

📖 문제 📃 코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Collections; import java.util.PriorityQueue; public class Main { static PriorityQueue heap = new PriorityQueue(Collections.reverseOrder()); public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int ..

백준[JAVA] 11726.2×n 타일링 - 자바

📖 문제 📃 코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { static Integer[] dp = new Integer[10008]; static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public static void main(String[] args) throws IOException { dp[0] = 0; dp[1] = 1; dp[2] = 2; dp[3] = 3; // dp[n] = dp[n-1] + dp[n-2] int N = Integer.par..

백준[JAVA] 9095.1, 2, 3 더하기 - 자바

📖 문제 📃 코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { static Integer[] dp = new Integer[11]; static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public static void main(String[] args) throws IOException { StringBuilder sb = new StringBuilder(); dp[0] = 0; dp[1] = 1; dp[2] = 2; dp[3] = 4; // dp[4] = ..

백준[JAVA] 1463.1로 만들기 - 자바

📖 문제 📃 코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { static Integer[] dp; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int X = Integer.parseInt(br.readLine()); dp = new Integer[X + 1]; dp[0] = dp[1] = 0; System.out.println(recur(X)); } pri..