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{ + 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 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{ + 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