본문 바로가기

백준/골드13

팀 빌딩 - JAVA, two pointer 출처 : https://www.acmicpc.net/problem/22945 코드 & 풀이 import java.io.*;import java.util.*;public class 백준_팀빌딩_22945 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine()); StringTokenizer st = new StringTokenizer(br.readLine()); int[] status = n.. 2025. 6. 9.
보이저 1호 - JAVA, 구현 출처 : https://www.acmicpc.net/problem/3987 코드 & 풀이 import java.io.*;import java.util.*;public class 백준_보이저1호_3987 { static int N, M; static int max_count; static int result_direct; static boolean is_voyager; static char[][] space; static int[] dx = {-1, 0, 1, 0}; // U R D L static int[] dy = {0, 1, 0, -1}; static int[][] mirror = { // /, \ {1, 3}, .. 2025. 6. 7.
두 개의 탑 - JAVA, Two Pointer, Prefix Sum 출처 : https://www.acmicpc.net/problem/2118 코드 & 풀이 import java.io.*;public class 백준_두개의탑_2118 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine()); int[] dist = new int[N]; for (int i = 0; i prefix 배열의 길이가 2배인 이유 ⇒ 5에서부터 시작하는 경우도 있으니까end의 .. 2025. 6. 6.
백준 1300. K 번째 수 - JAVA, 이분 탐색 출처 : https://www.acmicpc.net/problem/1300 코드 & 풀이 import java.io.*;public class 백준_K번째수_1300 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine()); int K = Integer.parseInt(br.readLine()); int low = 1; int high = K; int answer =.. 2025. 5. 23.
백준19238.스타트 택시 - JAVA, 구현, HashMap, List, BFS 출처 : https://www.acmicpc.net/problem/19238 코드 & 풀이 import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.*;/** 1. 손님별 택시와 최단 거리 구하기 -> BFS* -> 거리별 > 행 번호 > 열 번호* 2. 나온 거리를 택시가 갈 수 있는지 확인* 가능 => 연료 계산* 불가능 => return -1* */public class 백준_스타트택시_19238 { static int N, M, fuel; static int[][] city; static Taxi taxi; static Map passe.. 2025. 5. 16.
2169번 로봇 조종하기 - Python, DP 출처 : https://www.acmicpc.net/problem/2169 코드 import sys# 입력 처리data = sys.stdin.read().splitlines()N, M = map(int, data.pop(0).split(" "))mars = [list(map(int, data.pop(0).split(" "))) for _ in range(N)]dp = [[[-float('inf')] * 3 for _ in range(M)] for _ in range(N)]# 첫 번째 행 초기화dp[0][0][0] = dp[0][0][1] = dp[0][0][2] = mars[0][0]for y in range(1, M): dp[0][y][0] = dp[0][y][1] = dp[0][y][2] = d.. 2025. 4. 2.