본문 바로가기

Problem Solving/Baekjoon1337

[백준] 25943 양팔저울 - Greedy / Java • 문제 링크 25943번: 양팔저울 입력은 표준입력을 사용한다. 첫 번째 줄에 자갈 개수를 나타내는 양의 정수 $n$ ($2 ≤ n ≤ 10\,000$)이 주어진다. 다음 줄에 $n$ 개의 수들이 주어지는데, 이들은 번호 순서대로 자갈의 무게이다. 자 www.acmicpc.net • 풀이 코드 import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStreamWriter; public class Main { public static void main(String[] args) throws IOException { BufferedWriter bw = new BufferedWriter(new OutputStreamWri.. 2023. 10. 19.
[백준] 28256 초콜릿 보관함 - Graph Theory / Java • 문제 링크 28256번: 초콜릿 보관함 각 테스트 케이스마다, 화면의 표시가 올바르다면 1, 아니라면 0을 출력한다. www.acmicpc.net • 풀이 코드 import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Queue; import java.u.. 2023. 10. 18.
[백준] 18232 텔레포트 정거장 - Graph Theory / Java • 문제 링크 18232번: 텔레포트 정거장 첫 번째 줄에 정수 N, M이 공백으로 구분되어 주어진다. (2 ≤ N ≤ 300,000, 0 ≤ M ≤ min(N×(N-1)/2, 300,000)) 두 번째 줄에 정수 S, E가 공백으로 구분되어 주어진다. (1 ≤ S, E ≤ N, S ≠ E) 그 다음 줄부터 M www.acmicpc.net • 풀이 코드 import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStreamWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.List; import java.util.Queue; p.. 2023. 10. 17.
[백준] 26170 사과 빨리 먹기 - Graph Theory / Java • 문제 링크 26170번: 사과 빨리 먹기 (2, 3) -> (2, 2) -> (2, 1) -> (3, 1) -> (3, 0) -> (2, 0) -> (1, 0) -> (0, 0) -> (0, 1) -> (0, 2) 가 최소 이동으로 사과 3개를 먹는 경우이다. www.acmicpc.net • 풀이 코드 import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStreamWriter; public class Main { static int[][] mat = new int[5][5]; static boolean[][] visit = new boolean[5][5]; static int[] dy = {-1, 1, 0, 0.. 2023. 10. 16.
[백준] 26169 세 번 이내에 사과를 먹자 - Graph Theory / Java • 문제 링크 26169번: 세 번 이내에 사과를 먹자 5 x 5 크기의 보드가 주어진다. 보드는 1 x 1 크기의 정사각형 격자로 이루어져 있다. 보드의 격자는 사과가 1개 있는 격자, 장애물이 있는 격자, 빈칸으로 되어 있는 격자로 구분된다. 격자의 위치 www.acmicpc.net • 풀이 코드 import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStreamWriter; public class Main { static int[][] mat = new int[5][5]; static boolean[][] visit = new boolean[5][5]; static int[] dy = {-1, 1, 0, 0}, .. 2023. 10. 15.
[백준] 13237 Binary tree - Graph Theory / Java • 문제 링크 13237번: Binary tree A binary tree is a mathematical structure made of nodes where each node can have up to two children nodes. One child node will be called left child and the other right child. ch If node B is a child node of A, then we say that A is the parent node of B. In www.acmicpc.net • 풀이 코드 import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStreamWri.. 2023. 10. 14.