From 88217737c0d03dc7d479cfe24fb2e0bb18c936b8 Mon Sep 17 00:00:00 2001 From: ji <6531z@naver.com> Date: Mon, 1 May 2023 23:38:21 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[BOJ]=208980=20=ED=83=9D=EB=B0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/JIHANEOL.java" | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 "baekjoon/8980_\355\203\235\353\260\260/src/JIHANEOL.java" diff --git "a/baekjoon/8980_\355\203\235\353\260\260/src/JIHANEOL.java" "b/baekjoon/8980_\355\203\235\353\260\260/src/JIHANEOL.java" new file mode 100644 index 0000000..e637d9b --- /dev/null +++ "b/baekjoon/8980_\355\203\235\353\260\260/src/JIHANEOL.java" @@ -0,0 +1,76 @@ +import java.io.*; +import java.util.*; + +// 머리가 좋아야한다. 초딩들 무야 +public class JIHANEOL { + static BufferedReader br; + static StringTokenizer st; + static class Cupang implements Comparable{ + int from,to,cost; + + public Cupang(int from,int to, int cost) { + super(); + + this.from = from; + this.to = to; + this.cost = cost; + } + + @Override + public int compareTo(Cupang o) { + return this.to == o.to ? Integer.compare(this.from, o.from) : Integer.compare(this.to, o.to); + } + + } + public static int[] cp; + public static void main(String[] args) throws IOException { + br = new BufferedReader(new InputStreamReader(System.in)); + st = new StringTokenizer(br.readLine()); + int N = Integer.valueOf(st.nextToken()); + int C = Integer.valueOf(st.nextToken()); + cp = new int[N]; + int total = 0; + int M = Integer.valueOf(br.readLine()); + List list = new ArrayList(); + Arrays.fill(cp,C); + for(int i=0; i=0) { + total+=now.cost; + update(now.from, now.to, now.cost); + }else { + total+=min; + update(now.from, now.to, min); + } + } + System.out.println(total); + + } + // 최소 찾기 + static int find(int s, int e) { + int min = 10005; + for(int i=s; i Date: Mon, 1 May 2023 23:43:47 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[BOJ]=2014908=20=EA=B5=AC=EB=91=90=20?= =?UTF-8?q?=EC=88=98=EC=84=A0=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/JIHANEOL.java" | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 "baekjoon/14908_\352\265\254\353\221\220\354\210\230\354\204\240\352\263\265/src/JIHANEOL.java" diff --git "a/baekjoon/14908_\352\265\254\353\221\220\354\210\230\354\204\240\352\263\265/src/JIHANEOL.java" "b/baekjoon/14908_\352\265\254\353\221\220\354\210\230\354\204\240\352\263\265/src/JIHANEOL.java" new file mode 100644 index 0000000..fce9310 --- /dev/null +++ "b/baekjoon/14908_\352\265\254\353\221\220\354\210\230\354\204\240\352\263\265/src/JIHANEOL.java" @@ -0,0 +1,58 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; +import java.util.StringTokenizer; + + +public class JIHANEOL { + static BufferedReader br; + static StringTokenizer st; + static class Work implements Comparable{ + int no,t,s; + + public Work(int no,int t, int s){ + super(); + this.no = no; + this.t = t; + this.s = s; + } + // 작업 , 보상금 으로 그리디 하게 접근 똑똑하다. + @Override + public int compareTo(Work o) { + double a = this.t/(double)this.s; + double b = (double)o.t/o.s; + + if(a==b) { + return this.no - o.no; + } + return Double.compare(a, b); + } + + } + static List list = new ArrayList(); + public static void main(String[] args) throws IOException { + br = new BufferedReader(new InputStreamReader(System.in)); + int N = Integer.valueOf(br.readLine()); + + for(int i=1; i<=N; i++) { + st = new StringTokenizer(br.readLine()); + int t = Integer.valueOf(st.nextToken()); + int s = Integer.valueOf(st.nextToken()); + list.add(new Work(i,t, s)); + } + Collections.sort(list); + StringBuilder sb = new StringBuilder(); + + for(Work w : list) { + sb.append(w.no + " "); + } + System.out.println(sb); + + } + +} \ No newline at end of file From cbfcc850cddcf35c188a57afa41f2829891ab7da Mon Sep 17 00:00:00 2001 From: ji <6531z@naver.com> Date: Mon, 1 May 2023 23:50:56 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[BOJ]=2011967=20=EB=B6=88=EC=BC=9C=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/JIHANEOL.java" | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 "baekjoon/11967_\353\266\210\354\274\234\352\270\260/src/JIHANEOL.java" diff --git "a/baekjoon/11967_\353\266\210\354\274\234\352\270\260/src/JIHANEOL.java" "b/baekjoon/11967_\353\266\210\354\274\234\352\270\260/src/JIHANEOL.java" new file mode 100644 index 0000000..8c0338d --- /dev/null +++ "b/baekjoon/11967_\353\266\210\354\274\234\352\270\260/src/JIHANEOL.java" @@ -0,0 +1,87 @@ +import java.io.*; +import java.util.*; + +public class JIHANEOL { + static BufferedReader br; + static StringTokenizer st; + static boolean map[][],On[][]; + static boolean visited[][][]; + + static class Point{ + int x,y; + + public Point(int x, int y) { + super(); + this.x = x; + this.y = y; + } + } + public static void main(String[] args) throws IOException { + br = new BufferedReader(new InputStreamReader(System.in)); + st = new StringTokenizer(br.readLine()); + int N = Integer.valueOf(st.nextToken()); + int M = Integer.valueOf(st.nextToken()); + List[][] list = new List[N][N]; + for(int i=0; i q = new LinkedList(); + q.add(new int[] {0,0,1}); + map[0][0] = true; + visited[0][0][1] =true; + On = new boolean[N][N]; + while(!q.isEmpty()) { + int[] now = q.poll(); + int x = now[0]; + int y = now[1]; + int key = now[2]; + + // KEY 와 현재 turnOn과 비교 + if(turnOn!=key) continue; + // 불 킬수 있으면 키자.. + if(!On[x][y] && list[x][y].size()!=0) { + On[x][y] = true; + for(Point p : list[x][y]) { + if(map[p.x][p.y]==false) { + map[p.x][p.y] = true; + turnOn++; + } + } + } + for(int i=0; i<4; i++) { + int nx = x+ dx[i]; + int ny = y+ dy[i]; + + try { + if(map[nx][ny] && !visited[nx][ny][turnOn]) { + visited[nx][ny][turnOn]=true; + if(key Date: Tue, 2 May 2023 00:20:22 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[PRO]=2042861=20=EC=84=AC=20=EC=97=B0?= =?UTF-8?q?=EA=B2=B0=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/JIHANEOL.java" | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 "programmers/\354\204\254\354\227\260\352\262\260\355\225\230\352\270\260/src/JIHANEOL.java" diff --git "a/programmers/\354\204\254\354\227\260\352\262\260\355\225\230\352\270\260/src/JIHANEOL.java" "b/programmers/\354\204\254\354\227\260\352\262\260\355\225\230\352\270\260/src/JIHANEOL.java" new file mode 100644 index 0000000..5494688 --- /dev/null +++ "b/programmers/\354\204\254\354\227\260\352\262\260\355\225\230\352\270\260/src/JIHANEOL.java" @@ -0,0 +1,79 @@ +import java.util.Arrays; +import java.util.PriorityQueue; + +class Node implements Comparable{ + int from, to, cost; + + Node(int f,int t, int c){ + this.from = f; + this.to = t; + this.cost = c; + } + + @Override + public int compareTo(Node o) { + // TODO Auto-generated method stub + return this.cost - o.cost; + } + } +public class JIHANEOL { + public static void main(String[] args) { + + int n = 4; + int[][] costs = new int[][] { + {0,1,1}, + {0,2,2}, + {1,2,5}, + {1,3,1}, + {2,3,8} + }; + Solution s = new Solution(); + if (s.solution(n, costs)==4) { + System.out.println("정답"); + } else { + System.out.println("땡"); + } + + } +} + +class Solution { + int[] parents; + + public int solution(int n, int[][] costs) { + int answer = 0; + PriorityQueue pq = new PriorityQueue<>(); + // 진짜 바보다 n으로 해버렸네 ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ + for(int i =0; i