전체 글 352

구현 / 백준 20207 달력

문제 접근먼저 우선순위 큐 사용해서 정렬하고>> compareTo return 값은 맨날 헷갈리네;>> 오름차순이 this 먼저 날짜 배열하나 가지고 해당하는 각 일정의 날짜를 ++>> 이어지는 일정들 중 배열 값의 최대값이 직사각형의 높이가 됨 꽤 재밌었음풀이package gold;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.PriorityQueue;import java.util.StringTokenizer;public class G20207 { static class Plan implements Comparable { int s, e; ..

Algorithm 2025.12.22

구현 / 백준 1117 색칠 1

문제 접근골드 5맞냐?일단 그림 보고 그냥 무지성으로 배열 쓴 저를 혼내주십쇼.>> 너비와 높이 범위도 안보고 무지성 2차원 배열로 메모리 초과 다음은 메모리에서 정신 못차리고 2중 for문을 쓴 저를 혼내주십쇼.>> 당연히 시간 초과 y1, y2에 관한 높이는 for문을 돌릴 이유가 없다>> x와 상관없이 y2 - y1하면 되기 때문 많은 생각이 들게 하는 문제였다.풀이package gold;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.StringTokenizer;public class G1117 { public static void main(Strin..

Algorithm 2025.12.19

누적 합 / 백준 3020 개똥벌레

문제 접근2중 for문을 쓰면 시간 초과이므로 누적합 사용>> 이분탐색으로 푸는 방법도 존재풀이package gold;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.StringTokenizer;public class G3020 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokeni..

Algorithm 2025.12.19

DFS / 백준 12869 뮤탈리스크

문제 접근DFS로 풀이>> 체력이 깎이는 경우 6가지를 돌리며 최솟값 찾아가며 dp 배열 채움풀이package gold;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.StringTokenizer;public class G12869 { static int[][][] dp = new int[61][61][61]; static int[] attack = {9, 3, 1}; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedRe..

Algorithm 2025.12.17

DFS / 백준 17070 파이프 옮기기 1

문제 접근간단한 DFS 문제 다른 풀이 보니까 DP로도 풀었던데 한번 해봐야지풀이package gold;import java.util.*;import java.io.*;public class G17070 { static int n; static int[][] graph; static int cnt = 0; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); n = Integer.parseInt(br.readLine()); graph = new int[n][n]; for (int i = 0; i

Algorithm 2025.12.03

다익스트라 / 2021 KAKAO BLIND RECRUITMENT 택시 합승 요금

문제 접근합승 지점을 기준으로 풀이>> 다익스트라 사용풀이package lv2;import java.io.*;import java.util.*;class Taxi { static class Node implements Comparable{ int end, cost; public Node(int end, int cost){ this.end = end; this.cost = cost; } @Override public int compareTo(Node n){ return this.cost - n.cost; } } static ArrayList[] list; static int N; public int solution(int n, int s,..

Algorithm 2025.11.11