<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>메모메모</title>
    <link>https://lazybones1.tistory.com/</link>
    <description></description>
    <language>ko</language>
    <pubDate>Sat, 4 Jul 2026 17:31:56 +0900</pubDate>
    <generator>TISTORY</generator>
    <ttl>100</ttl>
    <managingEditor>owoowo</managingEditor>
    <item>
      <title>Softeer_지우는 소수를 좋아해_java</title>
      <link>https://lazybones1.tistory.com/192</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a title=&quot;Softeer_지우는 소수를 좋아해&quot; href=&quot;https://softeer.ai/practice/info.do?idx=1&amp;amp;eid=582&amp;amp;sw_prbl_sbms_sn=214008&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://softeer.ai/practice/info.do?idx=1&amp;amp;eid=582&amp;amp;sw_prbl_sbms_sn=214008&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1686883693758&quot; contenteditable=&quot;false&quot; data-ke-type=&quot;opengraph&quot; data-ke-align=&quot;alignCenter&quot; data-og-type=&quot;website&quot; data-og-title=&quot;Softeer&quot; data-og-description=&quot;연습문제를 담을 Set을 선택해주세요. 취소 확인&quot; data-og-host=&quot;softeer.ai&quot; data-og-source-url=&quot;https://softeer.ai/practice/info.do?idx=1&amp;amp;eid=582&amp;amp;sw_prbl_sbms_sn=214008&quot; data-og-url=&quot;https://softeer.ai/practice/info.do?eid=582&amp;amp;idx=1&amp;amp;sw_prbl_sbms_sn=214008&quot; data-og-image=&quot;&quot;&gt;&lt;a href=&quot;https://softeer.ai/practice/info.do?idx=1&amp;amp;eid=582&amp;amp;sw_prbl_sbms_sn=214008&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-source-url=&quot;https://softeer.ai/practice/info.do?idx=1&amp;amp;eid=582&amp;amp;sw_prbl_sbms_sn=214008&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url();&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;og-text&quot;&gt;
&lt;p class=&quot;og-title&quot; data-ke-size=&quot;size16&quot;&gt;Softeer&lt;/p&gt;
&lt;p class=&quot;og-desc&quot; data-ke-size=&quot;size16&quot;&gt;연습문제를 담을 Set을 선택해주세요. 취소 확인&lt;/p&gt;
&lt;p class=&quot;og-host&quot; data-ke-size=&quot;size16&quot;&gt;softeer.ai&lt;/p&gt;
&lt;/div&gt;
&lt;/a&gt;&lt;/figure&gt;
&lt;pre id=&quot;code_1686883712113&quot; class=&quot;bash&quot; data-ke-language=&quot;bash&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;import java.util.*;
import java.io.*;


public class Main
{
    private static List&amp;lt;int[]&amp;gt;[] road;
    private static int minLevel;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        int M = Integer.parseInt(st.nextToken()); // 길의 수

        minLevel = Integer.MAX_VALUE;
        // 길 정보 입력
        road = new List[N+1];
        for (int i = 1; i&amp;lt;= N; i++){
            road[i] = new ArrayList&amp;lt;&amp;gt;();
        }

        for (int i = 0; i &amp;lt; M; i++){
            st = new StringTokenizer(br.readLine());

            // 체육관 A, B / 필요레벨 C
            int A = Integer.parseInt(st.nextToken());
            int B = Integer.parseInt(st.nextToken());
            int C = Integer.parseInt(st.nextToken());

            road[A].add(new int[]{B, C});
            road[B].add(new int[]{A, C});
        }

        int ans = dijkstra(1, road, N);

        System.out.println(getNextPrime(ans));
    }

    public static int dijkstra(int start, List&amp;lt;int[]&amp;gt;[] road, int N){
        boolean[] visited = new boolean[N+1];
        int[] dist = new int[N+1];

        Arrays.fill(dist, Integer.MAX_VALUE);
        dist[start] = 0;

        PriorityQueue&amp;lt;int[]&amp;gt; pq = new PriorityQueue&amp;lt;&amp;gt;((o1, o2) -&amp;gt; o1[1] - o2[1]);
        pq.offer(new int[]{start, 0});

        while (!pq.isEmpty()){
            int[] now = pq.poll();

            if(dist[now[0]] &amp;lt; now[1]) continue;

            for (int[] next : road[now[0]]){
                int nextLevel = Math.max(now[1], next[1]);
                if (dist[next[0]] &amp;gt; nextLevel){
                    dist[next[0]] = nextLevel;
                    pq.offer(new int[]{next[0], dist[next[0]]});
                }
            }
        }
        return dist[N];
    }

    // num ~ 1000000000
    public static int getNextPrime(int num){
        for (int i = num+1; ; i++) {
            if (isPrime(i)) {
                return i;
            }
        }
    }

    public static boolean isPrime(int num){
        for (int i = 2; i&amp;lt;=Math.sqrt(num); i++){
            if (num%i == 0){
                return false;
            }
        }
        return true;
    }
}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>Algorithm/Softeer</category>
      <author>owoowo</author>
      <guid isPermaLink="true">https://lazybones1.tistory.com/192</guid>
      <comments>https://lazybones1.tistory.com/192#entry192comment</comments>
      <pubDate>Fri, 16 Jun 2023 11:48:34 +0900</pubDate>
    </item>
    <item>
      <title>programmers_3 x n 타일링_java</title>
      <link>https://lazybones1.tistory.com/191</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a title=&quot;programmers_3 x n 타일링&quot; href=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/12902&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://school.programmers.co.kr/learn/courses/30/lessons/12902&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1686369185968&quot; contenteditable=&quot;false&quot; data-ke-type=&quot;opengraph&quot; data-ke-align=&quot;alignCenter&quot; data-og-type=&quot;website&quot; data-og-title=&quot;프로그래머스&quot; data-og-description=&quot;코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.&quot; data-og-host=&quot;programmers.co.kr&quot; data-og-source-url=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/12902&quot; data-og-url=&quot;https://programmers.co.kr/&quot; data-og-image=&quot;https://scrap.kakaocdn.net/dn/xZno6/hySWqLk8Is/Hq2rvXSVjfvi64EtV12jak/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/hbtrR/hySW6ymtLn/B9clDmPmwcCKm9AC5IRD8k/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630&quot;&gt;&lt;a href=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/12902&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-source-url=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/12902&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url('https://scrap.kakaocdn.net/dn/xZno6/hySWqLk8Is/Hq2rvXSVjfvi64EtV12jak/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/hbtrR/hySW6ymtLn/B9clDmPmwcCKm9AC5IRD8k/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630');&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;og-text&quot;&gt;
&lt;p class=&quot;og-title&quot; data-ke-size=&quot;size16&quot;&gt;프로그래머스&lt;/p&gt;
&lt;p class=&quot;og-desc&quot; data-ke-size=&quot;size16&quot;&gt;코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.&lt;/p&gt;
&lt;p class=&quot;og-host&quot; data-ke-size=&quot;size16&quot;&gt;programmers.co.kr&lt;/p&gt;
&lt;/div&gt;
&lt;/a&gt;&lt;/figure&gt;
&lt;pre id=&quot;code_1686369188841&quot; class=&quot;bash&quot; data-ke-language=&quot;bash&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;class Solution {
    
    private final int mod = 1000000007;
    
    public int solution(int n) {
        int answer = 0;
        
        long[] dp = new long[n+1];
        
        // f(n)= f(n-2)*4 - f(n-4)
        dp[0]=1;
        dp[2]=3;
        
        for(int i=4; i&amp;lt;=n; i+=2){
            dp[i]= (dp[i-2]*4%mod -dp[i-4]%mod +mod)%mod;
        };
        
        answer = (int)dp[n];
        
        return answer;
    }
}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>Algorithm/Programmers</category>
      <author>owoowo</author>
      <guid isPermaLink="true">https://lazybones1.tistory.com/191</guid>
      <comments>https://lazybones1.tistory.com/191#entry191comment</comments>
      <pubDate>Sat, 10 Jun 2023 12:53:13 +0900</pubDate>
    </item>
    <item>
      <title>programmers_빛의 경로 사이클_java</title>
      <link>https://lazybones1.tistory.com/190</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a title=&quot;programmers_빛의 경로 사이클&quot; href=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/86052&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://school.programmers.co.kr/learn/courses/30/lessons/86052&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1686212849602&quot; contenteditable=&quot;false&quot; data-ke-type=&quot;opengraph&quot; data-ke-align=&quot;alignCenter&quot; data-og-type=&quot;website&quot; data-og-title=&quot;프로그래머스&quot; data-og-description=&quot;코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.&quot; data-og-host=&quot;programmers.co.kr&quot; data-og-source-url=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/86052&quot; data-og-url=&quot;https://programmers.co.kr/&quot; data-og-image=&quot;https://scrap.kakaocdn.net/dn/bA7z8b/hySWq4vd9e/7Ny71azkb50V6i9Bur4vOK/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/cG4kjB/hySVN7mVpT/woiiB7q08uFPKg0RPJUWJk/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630&quot;&gt;&lt;a href=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/86052&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-source-url=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/86052&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url('https://scrap.kakaocdn.net/dn/bA7z8b/hySWq4vd9e/7Ny71azkb50V6i9Bur4vOK/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/cG4kjB/hySVN7mVpT/woiiB7q08uFPKg0RPJUWJk/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630');&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;og-text&quot;&gt;
&lt;p class=&quot;og-title&quot; data-ke-size=&quot;size16&quot;&gt;프로그래머스&lt;/p&gt;
&lt;p class=&quot;og-desc&quot; data-ke-size=&quot;size16&quot;&gt;코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.&lt;/p&gt;
&lt;p class=&quot;og-host&quot; data-ke-size=&quot;size16&quot;&gt;programmers.co.kr&lt;/p&gt;
&lt;/div&gt;
&lt;/a&gt;&lt;/figure&gt;
&lt;pre id=&quot;code_1686212862460&quot; class=&quot;bash&quot; data-ke-language=&quot;bash&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;import java.util.*;

class Solution {
   private static int[][] delta = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}, }; // 우, 하, 좌, 상

    public int[] solution(String[] grid) {
        int[] answer = {};

        List&amp;lt;Integer&amp;gt; answerList = new ArrayList&amp;lt;&amp;gt;();

        Set&amp;lt;Node&amp;gt; nodes = new HashSet&amp;lt;&amp;gt;();
        for (int i = 0; i&amp;lt;grid.length; i++){
            for (int j = 0; j&amp;lt;grid[i].length(); j++){
                for (int d = 0; d&amp;lt;4; d++){
                    if (!nodes.contains(new Node(i, j, d))){
                        int res = findCycle(i, j, d, nodes, grid);
                        answerList.add(res);
                    }
                }
            }
        }

        // list to array
        answer = new int[answerList.size()];
        for (int i = 0; i&amp;lt;answerList.size(); i++){
            answer[i] = answerList.get(i);
        }

        // 오름차순 정렬
        Arrays.sort(answer);

        return answer;
    }

    public int findCycle(int y, int x, int dir, Set&amp;lt;Node&amp;gt; nodes, String[] grid){
        int cnt = 0;
        Node now = new Node(y, x, dir);

        while (true){
            if (nodes.contains(now)){ // 사이클 발생
                return cnt;
            }
            nodes.add(now);
            int[] next = move(grid, now.y, now.x, now.dir);
            now = new Node(next[0], next[1], next[2]);
            cnt++;
        }
    }

    // StackOverFlow 에러 발생 - 재귀가 너무 많아 발생
//    public static int dfs(int y, int x, int dir, int cnt, Set&amp;lt;Node&amp;gt; nodes, String[] grid){
//        Node now = new Node(y, x, dir);
//        if (nodes.contains(now)){ // 사이클 발생
//            return cnt;
//        }
//
//        // 방문처리
//        nodes.add(now);
//        int[] next = move(grid, y, x, dir);
//        return dfs(next[0], next[1], next[2], cnt+1,  nodes, grid);
//    }

    public int[] move(String[] grid, int y, int x, int dir){

        // 방향 전환
        if (grid[y].charAt(x) == 'R'){
            dir = (dir == 3 ? 0 : dir+1);
        }else if (grid[y].charAt(x) == 'L'){
            dir = (dir == 0 ? 3 : dir-1);
        }
        // +grid.lenth : 음수로 되는 경우 방지
        int nexyy = (y + delta[dir][0] + grid.length) % grid.length;
        int nexyx = (x + delta[dir][1] + grid[y].length()) % grid[y].length();

        int[] next = new int[]{nexyy, nexyx, dir};

        return next;
    }

    public class Node{
        int y,  x, dir;
        public Node(int y, int x, int dir){
            this.y = y;
            this.x = x;
            this.dir = dir;
        }

		// set에서 비교하기 위해 작성
        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Node node = (Node) o;
            return y == node.y &amp;amp;&amp;amp; x == node.x &amp;amp;&amp;amp; dir == node.dir;
        }

        @Override
        public int hashCode() {
            return Objects.hash(y, x, dir);
        }
    }
}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>Algorithm/Programmers</category>
      <author>owoowo</author>
      <guid isPermaLink="true">https://lazybones1.tistory.com/190</guid>
      <comments>https://lazybones1.tistory.com/190#entry190comment</comments>
      <pubDate>Thu, 8 Jun 2023 17:27:47 +0900</pubDate>
    </item>
    <item>
      <title>programmers_단체사진 찍기_java</title>
      <link>https://lazybones1.tistory.com/189</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a title=&quot;programmers_단체사진 찍기&quot; href=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/1835&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://school.programmers.co.kr/learn/courses/30/lessons/1835&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1685766541171&quot; contenteditable=&quot;false&quot; data-ke-type=&quot;opengraph&quot; data-ke-align=&quot;alignCenter&quot; data-og-type=&quot;website&quot; data-og-title=&quot;프로그래머스&quot; data-og-description=&quot;코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.&quot; data-og-host=&quot;programmers.co.kr&quot; data-og-source-url=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/1835&quot; data-og-url=&quot;https://programmers.co.kr/&quot; data-og-image=&quot;https://scrap.kakaocdn.net/dn/iHDT0/hySR1KzTzo/vE4j6Ct9MJMmkmI1iS3Eu0/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/laljO/hySRXaj2ry/X2HZcYGdyS0C9JjWPfRgS1/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630&quot;&gt;&lt;a href=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/1835&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-source-url=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/1835&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url('https://scrap.kakaocdn.net/dn/iHDT0/hySR1KzTzo/vE4j6Ct9MJMmkmI1iS3Eu0/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/laljO/hySRXaj2ry/X2HZcYGdyS0C9JjWPfRgS1/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630');&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;og-text&quot;&gt;
&lt;p class=&quot;og-title&quot; data-ke-size=&quot;size16&quot;&gt;프로그래머스&lt;/p&gt;
&lt;p class=&quot;og-desc&quot; data-ke-size=&quot;size16&quot;&gt;코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.&lt;/p&gt;
&lt;p class=&quot;og-host&quot; data-ke-size=&quot;size16&quot;&gt;programmers.co.kr&lt;/p&gt;
&lt;/div&gt;
&lt;/a&gt;&lt;/figure&gt;
&lt;pre id=&quot;code_1685766541543&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;import java.util.*;

class Solution {
    private static String[] friends = {&quot;A&quot;, &quot;C&quot;, &quot;F&quot;, &quot;J&quot;, &quot;M&quot;, &quot;N&quot;, &quot;R&quot;, &quot;T&quot;};
    public int solution(int n, String[] data) {
        int answer = 0;

        answer = dfs(&quot;&quot;, new boolean[8], data);

        return answer;
    }

    private int dfs(String names, boolean[] isVisited, String[] datas) {
        if (names.length() == 7) {
            if (isSatisfaction(names, datas)) {
                return 1;
            }
            return 0;
        }
        
        int res = 0;
        for (int i = 0; i &amp;lt; 8; i++) {
            if (!isVisited[i]) {
                isVisited[i] = true;
                res += dfs( names + friends[i], isVisited, datas);
                isVisited[i] = false;
            }
        }
        return res;
    }

    // 만족 여부
    public boolean isSatisfaction(String names, String[] datas) {
        for (String data : datas) {
            int f1 = names.indexOf(data.charAt(0)); 
            int f2 = names.indexOf(data.charAt(2)); 
            char op = data.charAt(3);
            int dist = data.charAt(4) -'0'; 
            
            if (op == '=') {
                if (!(Math.abs(f1 - f2) == dist+1)) return false;
            } else if (op == '&amp;gt;') {
                if (!(Math.abs(f1 - f2) &amp;gt; dist+1)) return false;
            } else if (op == '&amp;lt;') {
                if (!(Math.abs(f1 - f2) &amp;lt; dist+1)) return false;
            }
        }
        return true;
    }
}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>Algorithm/Programmers</category>
      <author>owoowo</author>
      <guid isPermaLink="true">https://lazybones1.tistory.com/189</guid>
      <comments>https://lazybones1.tistory.com/189#entry189comment</comments>
      <pubDate>Sat, 3 Jun 2023 13:29:05 +0900</pubDate>
    </item>
    <item>
      <title>programmers_유사 칸토어 비트열_java</title>
      <link>https://lazybones1.tistory.com/188</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a title=&quot;programmers_유사 칸토어 비트열&quot; href=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/148652&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://school.programmers.co.kr/learn/courses/30/lessons/148652&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1685677117695&quot; contenteditable=&quot;false&quot; data-ke-type=&quot;opengraph&quot; data-ke-align=&quot;alignCenter&quot; data-og-type=&quot;website&quot; data-og-title=&quot;프로그래머스&quot; data-og-description=&quot;코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.&quot; data-og-host=&quot;programmers.co.kr&quot; data-og-source-url=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/148652&quot; data-og-url=&quot;https://programmers.co.kr/&quot; data-og-image=&quot;https://scrap.kakaocdn.net/dn/vyxHd/hySQDcHrMv/KBn08pRCaMk628lZWhdeE0/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/ecHfMD/hySQBFWHj1/7asuYb4lhec15IHrEITjTk/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630&quot;&gt;&lt;a href=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/148652&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-source-url=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/148652&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url('https://scrap.kakaocdn.net/dn/vyxHd/hySQDcHrMv/KBn08pRCaMk628lZWhdeE0/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/ecHfMD/hySQBFWHj1/7asuYb4lhec15IHrEITjTk/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630');&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;og-text&quot;&gt;
&lt;p class=&quot;og-title&quot; data-ke-size=&quot;size16&quot;&gt;프로그래머스&lt;/p&gt;
&lt;p class=&quot;og-desc&quot; data-ke-size=&quot;size16&quot;&gt;코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.&lt;/p&gt;
&lt;p class=&quot;og-host&quot; data-ke-size=&quot;size16&quot;&gt;programmers.co.kr&lt;/p&gt;
&lt;/div&gt;
&lt;/a&gt;&lt;/figure&gt;
&lt;pre id=&quot;code_1685677142792&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;class Solution {
    public int solution(int n, long l, long r) {
        int answer = 0;

        answer = findOne(n, l, r, 1);

        return answer;
    }

    public int findOne(int n, long l, long r, long idx) {
        if (n == 0){
            return 1;
        }
        
        int num = 0;
        long p = (long) Math.pow(5, n-1); // 범위
        for (int i =0; i&amp;lt;5; i++){
        
        	// 2 = 0, 범위를 넘어가는 경우 제외
            if (i == 2 || r &amp;lt; (idx + p * i) || (idx + p * (i+1) -1) &amp;lt; l) continue;
            num += findOne(n-1, l, r, (idx + p * i));
        }
        return num;
    }

}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>Algorithm/Programmers</category>
      <author>owoowo</author>
      <guid isPermaLink="true">https://lazybones1.tistory.com/188</guid>
      <comments>https://lazybones1.tistory.com/188#entry188comment</comments>
      <pubDate>Fri, 2 Jun 2023 12:39:09 +0900</pubDate>
    </item>
    <item>
      <title>programmers_택배 배달과 수거하기_java</title>
      <link>https://lazybones1.tistory.com/187</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a title=&quot;programmers_택배 배달과 수거하기&quot; href=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/150369&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://school.programmers.co.kr/learn/courses/30/lessons/150369&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1685602317306&quot; contenteditable=&quot;false&quot; data-ke-type=&quot;opengraph&quot; data-ke-align=&quot;alignCenter&quot; data-og-type=&quot;website&quot; data-og-title=&quot;프로그래머스&quot; data-og-description=&quot;코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.&quot; data-og-host=&quot;programmers.co.kr&quot; data-og-source-url=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/150369&quot; data-og-url=&quot;https://programmers.co.kr/&quot; data-og-image=&quot;https://scrap.kakaocdn.net/dn/bHnTLi/hySPdMNOOy/mURsN8O1FVBcv05aXLKQiK/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/bpO69y/hySPrEhDxD/YqjskgsneTWSBrgjKTEwU1/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630&quot;&gt;&lt;a href=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/150369&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-source-url=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/150369&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url('https://scrap.kakaocdn.net/dn/bHnTLi/hySPdMNOOy/mURsN8O1FVBcv05aXLKQiK/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/bpO69y/hySPrEhDxD/YqjskgsneTWSBrgjKTEwU1/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630');&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;og-text&quot;&gt;
&lt;p class=&quot;og-title&quot; data-ke-size=&quot;size16&quot;&gt;프로그래머스&lt;/p&gt;
&lt;p class=&quot;og-desc&quot; data-ke-size=&quot;size16&quot;&gt;코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.&lt;/p&gt;
&lt;p class=&quot;og-host&quot; data-ke-size=&quot;size16&quot;&gt;programmers.co.kr&lt;/p&gt;
&lt;/div&gt;
&lt;/a&gt;&lt;/figure&gt;
&lt;pre id=&quot;code_1685602320826&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;class Solution {
    public long solution(int cap, int n, int[] deliveries, int[] pickups) {
        long answer = 0;

        int give = 0; // 배달
        int get = 0; // 수거

        for (int i = n; i&amp;gt;0; i--){
            if (deliveries[i-1] != 0 || pickups[i-1] != 0){
                int cnt = 0; // 해당 장소 방문 필요 횟수
                // 해당 장소에 방문 필요 횟수 구하기
                while(give &amp;lt; deliveries[i-1] || get &amp;lt; pickups[i-1]){ 
                    cnt++;
                    give += cap;
                    get += cap;
                }
                // 방문 하고 남은 것
                give -= deliveries[i-1];
                get -=  pickups[i-1];
                
                answer += (long)(i*cnt*2); // 거리 * 반복횟수 * 왕복
            }
        }

        return answer;
    }
}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>Algorithm/Programmers</category>
      <author>owoowo</author>
      <guid isPermaLink="true">https://lazybones1.tistory.com/187</guid>
      <comments>https://lazybones1.tistory.com/187#entry187comment</comments>
      <pubDate>Thu, 1 Jun 2023 15:52:03 +0900</pubDate>
    </item>
    <item>
      <title>programmers_교점에 별 만들기_java</title>
      <link>https://lazybones1.tistory.com/186</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a title=&quot;programmers_교점에 별 만들기&quot; href=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/87377&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://school.programmers.co.kr/learn/courses/30/lessons/87377&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1685587579719&quot; contenteditable=&quot;false&quot; data-ke-type=&quot;opengraph&quot; data-ke-align=&quot;alignCenter&quot; data-og-type=&quot;website&quot; data-og-title=&quot;프로그래머스&quot; data-og-description=&quot;코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.&quot; data-og-host=&quot;programmers.co.kr&quot; data-og-source-url=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/87377&quot; data-og-url=&quot;https://programmers.co.kr/&quot; data-og-image=&quot;https://scrap.kakaocdn.net/dn/kX2Gg/hySQJb6APE/0GN8BTGDCAD73WYPt60dO0/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/bwSPQT/hySQzAyXZj/YEuHSoJJZKZ2ONVgMkqph0/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630&quot;&gt;&lt;a href=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/87377&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-source-url=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/87377&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url('https://scrap.kakaocdn.net/dn/kX2Gg/hySQJb6APE/0GN8BTGDCAD73WYPt60dO0/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/bwSPQT/hySQzAyXZj/YEuHSoJJZKZ2ONVgMkqph0/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630');&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;og-text&quot;&gt;
&lt;p class=&quot;og-title&quot; data-ke-size=&quot;size16&quot;&gt;프로그래머스&lt;/p&gt;
&lt;p class=&quot;og-desc&quot; data-ke-size=&quot;size16&quot;&gt;코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.&lt;/p&gt;
&lt;p class=&quot;og-host&quot; data-ke-size=&quot;size16&quot;&gt;programmers.co.kr&lt;/p&gt;
&lt;/div&gt;
&lt;/a&gt;&lt;/figure&gt;
&lt;pre id=&quot;code_1685587607908&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;import java.util.*;

class Solution {

    public String[] solution(int[][] line) {
        String[] answer = {};

        long miny = Long.MAX_VALUE;
        long maxy = Long.MIN_VALUE;
        long minx = Long.MAX_VALUE;
        long maxx = Long.MIN_VALUE;

        // 정수 값을 갖는 교점 리스트
        List&amp;lt;long[]&amp;gt; pointList = new ArrayList&amp;lt;&amp;gt;();
        for (int i = 0; i&amp;lt;line.length; i++){
            for (int j = i+1; j&amp;lt;line.length; j++){
                long[] intersectionPoint = findIntersectionPoint(line[i], line[j]);
                if (intersectionPoint != null){
                    miny = Math.min(miny, intersectionPoint[1]);
                    maxy = Math.max(maxy, intersectionPoint[1]);
                    minx = Math.min(minx, intersectionPoint[0]);
                    maxx = Math.max(maxx, intersectionPoint[0]);

                    pointList.add(intersectionPoint);
                }
            }
        }

        // map 배열 생성 및 초기화
        char[][] map = new char[(int)(maxy - miny + 1)][(int)(maxx - minx + 1)];
        for (int i = 0; i&amp;lt;map.length; i++){
            Arrays.fill(map[i], '.');
        }

        // 교점 입력
        for (long[] point : pointList){
            int x = (int)(point[0] - minx);
            int y = (int)(point[1] - miny);
            map[y][x] = '*';
        }

        // char[][] -&amp;gt; String[]
        // 음수가 아래로 가도록
        answer = new String[map.length];
        for (int i = 0; i&amp;lt;map.length; i++){
            StringBuilder sb = new StringBuilder();
            for (int j = 0; j&amp;lt;map[i].length; j++){
                sb.append(map[i][j]);
            }
            answer[map.length - i - 1] = sb.toString();
        }

        return answer;
    }

    // x, y가 정수 값인 교점 찾기(int -&amp;gt; 오버플로우, double -&amp;gt; 오류)
    public long[] findIntersectionPoint(int[] line1, int[] line2){
        long A = line1[0];
        long B = line1[1];
        long E = line1[2];
        long C = line2[0];
        long D = line2[1];
        long F = line2[2];

        long[] point = new long[2];

        if((A * D - B * C) != 0){
            if((B * F - E * D) % (A * D - B * C) == 0){
                point[0] = (B * F - E * D) / (A * D - B * C);
            }else{
                return null;
            }
            if((E * C - A * F) % (A * D - B * C) == 0){
                point[1] = (E * C - A * F) / (A * D - B * C);
            }else{
                return null;
            }
        }else {
            return null;
        }

        return point;
    }

}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>Algorithm/Programmers</category>
      <author>owoowo</author>
      <guid isPermaLink="true">https://lazybones1.tistory.com/186</guid>
      <comments>https://lazybones1.tistory.com/186#entry186comment</comments>
      <pubDate>Thu, 1 Jun 2023 11:46:53 +0900</pubDate>
    </item>
    <item>
      <title>programmers_카카오프렌즈 컬러링북_java</title>
      <link>https://lazybones1.tistory.com/185</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a title=&quot;programmers_카카오프렌즈 컬러링북&quot; href=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/1829&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://school.programmers.co.kr/learn/courses/30/lessons/1829&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1685528587139&quot; contenteditable=&quot;false&quot; data-ke-type=&quot;opengraph&quot; data-ke-align=&quot;alignCenter&quot; data-og-type=&quot;website&quot; data-og-title=&quot;프로그래머스&quot; data-og-description=&quot;코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.&quot; data-og-host=&quot;programmers.co.kr&quot; data-og-source-url=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/1829&quot; data-og-url=&quot;https://programmers.co.kr/&quot; data-og-image=&quot;https://scrap.kakaocdn.net/dn/nXKdI/hySPthd5oK/kGDczp6zt2cjVhsDVFNW60/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/whufH/hySPfXASt1/3i3doClqI7IytGRIAOuGH0/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630&quot;&gt;&lt;a href=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/1829&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-source-url=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/1829&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url('https://scrap.kakaocdn.net/dn/nXKdI/hySPthd5oK/kGDczp6zt2cjVhsDVFNW60/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/whufH/hySPfXASt1/3i3doClqI7IytGRIAOuGH0/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630');&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;og-text&quot;&gt;
&lt;p class=&quot;og-title&quot; data-ke-size=&quot;size16&quot;&gt;프로그래머스&lt;/p&gt;
&lt;p class=&quot;og-desc&quot; data-ke-size=&quot;size16&quot;&gt;코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.&lt;/p&gt;
&lt;p class=&quot;og-host&quot; data-ke-size=&quot;size16&quot;&gt;programmers.co.kr&lt;/p&gt;
&lt;/div&gt;
&lt;/a&gt;&lt;/figure&gt;
&lt;pre id=&quot;code_1685528592347&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;import java.util.*;

class Solution {
    
    public static int[][] delta = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}}; //상 하 좌 우

    public int[] solution(int m, int n, int[][] picture) {
        int numberOfArea = 0;
        int maxSizeOfOneArea = 0;

        boolean[][] visited = new boolean[m][n];
        for (int i = 0; i&amp;lt;m; i++){
            for (int j = 0; j&amp;lt;n; j++){
                if (!visited[i][j] &amp;amp;&amp;amp; picture[i][j] != 0){
                    numberOfArea++;
                    maxSizeOfOneArea = Math.max(maxSizeOfOneArea, findArea(m, n, picture, i, j, visited));
                }
            }
        }

        int[] answer = new int[2];
        answer[0] = numberOfArea;
        answer[1] = maxSizeOfOneArea;
        return answer;
    }

    public int findArea(int m, int n, int[][] picture, int y, int x, boolean[][] visited){
        Queue&amp;lt;int[]&amp;gt; queue = new LinkedList&amp;lt;&amp;gt;();
        queue.offer(new int[]{y, x});
        int cnt = 0;

        while (!queue.isEmpty()){
            int[] now = queue.poll();

            if (visited[now[0]][now[1]]) continue;
            visited[now[0]][now[1]] = true;
            cnt++;

            for (int i = 0; i&amp;lt; 4; i++){
                int nexty = now[0] + delta[i][0];
                int nextx = now[1] + delta[i][1];

                if (0&amp;lt;= nexty &amp;amp;&amp;amp; nexty &amp;lt; m
                        &amp;amp;&amp;amp; 0&amp;lt;= nextx &amp;amp;&amp;amp; nextx &amp;lt; n
                        &amp;amp;&amp;amp; !visited[nexty][nextx]
                        &amp;amp;&amp;amp; picture[nexty][nextx] == picture[now[0]][now[1]]
                ){
                    queue.offer(new int[]{nexty, nextx});
                }
            }
        }

        return cnt;
    }
}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>Algorithm/Programmers</category>
      <author>owoowo</author>
      <guid isPermaLink="true">https://lazybones1.tistory.com/185</guid>
      <comments>https://lazybones1.tistory.com/185#entry185comment</comments>
      <pubDate>Wed, 31 May 2023 19:23:15 +0900</pubDate>
    </item>
    <item>
      <title>programmers_양궁대회_java</title>
      <link>https://lazybones1.tistory.com/184</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a title=&quot;programmers_양궁대회&quot; href=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/92342&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://school.programmers.co.kr/learn/courses/30/lessons/92342&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1685329189058&quot; contenteditable=&quot;false&quot; data-ke-type=&quot;opengraph&quot; data-ke-align=&quot;alignCenter&quot; data-og-type=&quot;website&quot; data-og-title=&quot;프로그래머스&quot; data-og-description=&quot;코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.&quot; data-og-host=&quot;programmers.co.kr&quot; data-og-source-url=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/92342&quot; data-og-url=&quot;https://programmers.co.kr/&quot; data-og-image=&quot;https://scrap.kakaocdn.net/dn/bmlGg1/hySNhAuZYZ/fgajeYhnAbqPJNnw7gGhIk/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/btW9h9/hySNaH8LYf/BKyK3PfhmbK6nFFDVkL4KK/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630&quot;&gt;&lt;a href=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/92342&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-source-url=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/92342&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url('https://scrap.kakaocdn.net/dn/bmlGg1/hySNhAuZYZ/fgajeYhnAbqPJNnw7gGhIk/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/btW9h9/hySNaH8LYf/BKyK3PfhmbK6nFFDVkL4KK/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630');&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;og-text&quot;&gt;
&lt;p class=&quot;og-title&quot; data-ke-size=&quot;size16&quot;&gt;프로그래머스&lt;/p&gt;
&lt;p class=&quot;og-desc&quot; data-ke-size=&quot;size16&quot;&gt;코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.&lt;/p&gt;
&lt;p class=&quot;og-host&quot; data-ke-size=&quot;size16&quot;&gt;programmers.co.kr&lt;/p&gt;
&lt;/div&gt;
&lt;/a&gt;&lt;/figure&gt;
&lt;pre id=&quot;code_1685329260835&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;class Solution {
    private static int[] hit;
    private static int diff;
    private static boolean end;

    public int[] solution(int n, int[] info) {
        int[] answer = {};
        hit = new int[11];
        end = false;
        diff = 0;
        dfs(n, info, 10, 0, 0, new int[11]);

        if (end){
            answer = hit;
        }else {
            answer = new int[]{-1};
        }

        return answer;
    }

// 완전탐색
    public void dfs(int n, int[] info, int point, int apeachPoint, int ryanPoint, int[] tt){
        if (point == 0){
            if (apeachPoint &amp;lt; ryanPoint){
                if (n &amp;gt; 0){
                    tt[10 - point] = n;
                }
                if (diff &amp;lt; ryanPoint - apeachPoint){ // 점수차가 더 큰 경우
                    diff = ryanPoint - apeachPoint;
                    hit = copy(tt);
                }else if(diff == ryanPoint - apeachPoint){
                    if (!comepare(hit, tt)){ // 더 적은 점수를 많이 맞춘 우
                        hit = copy(tt);
                    }
                }

                end = true;
            }
            tt[10 - point] = 0;
            return;
        }

        // 어피치가 해당 점수를 갖는 경우
        if(info[10 - point] &amp;gt; 0){
            tt[10 - point] = 0;
            dfs(n, info, point - 1, apeachPoint + point, ryanPoint, tt);
        }else{ // 둘다 점수를 갖지 않는 경우
            tt[10 - point] = 0;
            dfs(n, info, point - 1, apeachPoint, ryanPoint, tt);
        }
        // 라이언이 해당 점수를 갖는 경우
        if(n - info[10 - point] -1 &amp;gt;= 0){
            tt[10 - point] = info[10 - point] + 1;
            dfs(n - info[10 - point] - 1, info, point - 1, apeachPoint, ryanPoint + point, tt);
        }
    }

// 적은 점수에 많이 맞춘 것 찾기
    public boolean comepare(int[] oriArr, int[] newArr){
        for (int i = 10; i&amp;gt;=0; i--){
            if (oriArr[i] &amp;lt; newArr[i]){
                return false;
            } else if (oriArr[i] &amp;gt; newArr[i]) {
                return true;
            }
        }
        return true;
    }
    
// 배열 복사
    public int[] copy(int[] arr){
        int[] newArr = new int[arr.length];
        for (int i = 0; i&amp;lt;arr.length; i++){
            newArr[i] = arr[i];
        }
        return newArr;
    }
}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>Algorithm/Programmers</category>
      <author>owoowo</author>
      <guid isPermaLink="true">https://lazybones1.tistory.com/184</guid>
      <comments>https://lazybones1.tistory.com/184#entry184comment</comments>
      <pubDate>Mon, 29 May 2023 12:01:06 +0900</pubDate>
    </item>
    <item>
      <title>programmers_과제 진행하기_java</title>
      <link>https://lazybones1.tistory.com/183</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a title=&quot;programmers_과제 진행하기&quot; href=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/176962&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://school.programmers.co.kr/learn/courses/30/lessons/176962&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1685090377058&quot; contenteditable=&quot;false&quot; data-ke-type=&quot;opengraph&quot; data-ke-align=&quot;alignCenter&quot; data-og-type=&quot;website&quot; data-og-title=&quot;프로그래머스&quot; data-og-description=&quot;코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.&quot; data-og-host=&quot;programmers.co.kr&quot; data-og-source-url=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/176962&quot; data-og-url=&quot;https://programmers.co.kr/&quot; data-og-image=&quot;https://scrap.kakaocdn.net/dn/gyzFR/hySKweLVYf/tJWzcbDSWfXZPhfS8WXTj1/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/bXW2cL/hySLAmiVKT/Cn2iMSb7LM5xUb9c8RhZkK/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630&quot;&gt;&lt;a href=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/176962&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-source-url=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/176962&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url('https://scrap.kakaocdn.net/dn/gyzFR/hySKweLVYf/tJWzcbDSWfXZPhfS8WXTj1/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/bXW2cL/hySLAmiVKT/Cn2iMSb7LM5xUb9c8RhZkK/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630');&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;og-text&quot;&gt;
&lt;p class=&quot;og-title&quot; data-ke-size=&quot;size16&quot;&gt;프로그래머스&lt;/p&gt;
&lt;p class=&quot;og-desc&quot; data-ke-size=&quot;size16&quot;&gt;코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.&lt;/p&gt;
&lt;p class=&quot;og-host&quot; data-ke-size=&quot;size16&quot;&gt;programmers.co.kr&lt;/p&gt;
&lt;/div&gt;
&lt;/a&gt;&lt;/figure&gt;
&lt;pre id=&quot;code_1685090378315&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;import java.util.*;

class Solution {    
    public static String[] solution(String[][] plans) {
        String[] answer = new String[plans.length];

        PriorityQueue&amp;lt;Plan&amp;gt; readyQueue = new PriorityQueue&amp;lt;&amp;gt;(); // 남은 과제 우선순위 큐
        Stack&amp;lt;Plan&amp;gt; pauseQueue = new Stack&amp;lt;&amp;gt;(); // 중지 과제 스택

        for (String[] plan : plans){ // 우선순위 큐 입력
            readyQueue.offer(new Plan(plan));
        }

        int idx = 0; // answer 인덱스
        
        // 과제 실행
        Plan now = readyQueue.poll();
        while (true){
            Plan next = null;
            if (!readyQueue.isEmpty()){ // 새로운 과제가 존재하는 경우 
                next = readyQueue.peek();
            }else { // 새로운 과제가 더이상 없는 경우
                answer[idx++] = now.name;
                break;
            }

            if (now.start + now.playtime &amp;gt; next.start){ // 새로운 과제 시작
                pauseQueue.push(new Plan(now.name, next.start, now.playtime - (next.start - now.start))); // 실행중 과제 스택에 추가
                now = readyQueue.poll();
            }
            else { // 현재 과제 종료
                answer[idx++] = now.name;
                if (!pauseQueue.isEmpty()){
                    int t = now.start + now.playtime;
                    now = pauseQueue.pop();
                    now.start = t; // 시작 시간 초기화
                }else {
                    now = readyQueue.poll();
                }
            }
        }

        // 중지 목록 모두 실행
        while (!pauseQueue.isEmpty()){
            now = pauseQueue.pop();
            answer[idx++] = now.name;
        }

        return answer;
    }



    public static int timeToMin(String time){
        int res = 0;
        String[] t = time.split(&quot;:&quot;);
        res += Integer.parseInt(t[1]) + Integer.parseInt(t[0]) * 60;
        return res;
    }

    public static class Plan implements Comparable&amp;lt;Plan&amp;gt;{
        String name;
        int start;
        int playtime;
        public Plan(String[] plan){
            this.name = plan[0];
            this.start = timeToMin(plan[1]);
            this.playtime = Integer.parseInt(plan[2]);
        }

        public Plan(String name, int start, int playtime){
            this.name = name;
            this.start = start;
            this.playtime = playtime;
        }

        @Override
        public int compareTo(Plan o) {
            return this.start - o.start;
        }

        @Override
        public String
        toString() {
            return &quot;Plan{&quot; +
                    &quot;name='&quot; + name + '\'' +
                    &quot;, start=&quot; + start +
                    &quot;, playtime=&quot; + playtime +
                    '}';
        }
    }
}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>Algorithm/Programmers</category>
      <author>owoowo</author>
      <guid isPermaLink="true">https://lazybones1.tistory.com/183</guid>
      <comments>https://lazybones1.tistory.com/183#entry183comment</comments>
      <pubDate>Fri, 26 May 2023 17:39:40 +0900</pubDate>
    </item>
  </channel>
</rss>