<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Dogfootruler Kim</title>
    <link>https://jainn.tistory.com/</link>
    <description>insta @uuuuujinn</description>
    <language>ko</language>
    <pubDate>Mon, 13 Jul 2026 20:56:14 +0900</pubDate>
    <generator>TISTORY</generator>
    <ttl>100</ttl>
    <managingEditor>jainn</managingEditor>
    <image>
      <title>Dogfootruler Kim</title>
      <url>https://tistory1.daumcdn.net/tistory/3919189/attach/9161bc7bbb344899aa1149985c6f7b65</url>
      <link>https://jainn.tistory.com</link>
    </image>
    <item>
      <title>[SWEA] 3996:Poker(Java 자바)</title>
      <link>https://jainn.tistory.com/389</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;풀이 및 소스코드&lt;/p&gt;
&lt;pre id=&quot;code_1648539697215&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;

class Solution {
	static Card[] selected, cards;
	static int res;

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

		int T = Integer.parseInt(br.readLine());

		for (int test_case = 1; test_case &amp;lt;= T; test_case++) {
			cards = new Card[7];
			for (int i = 0; i &amp;lt; 7; i++) {
				st = new StringTokenizer(br.readLine());
				char m = st.nextToken().charAt(0);
				String tmpn = st.nextToken();
				int n = Integer.parseInt(tmpn);
				if (tmpn.endsWith(&quot;Ace&quot;)) {
					n = 1;
				} else if (tmpn.endsWith(&quot;Jack&quot;)) {
					n = 11;
				} else if (tmpn.endsWith(&quot;Queen&quot;)) {
					n = 12;
				} else if (tmpn.endsWith(&quot;King&quot;)) {
					n = 13;
				} else if (tmpn.endsWith(&quot;14&quot;)) {
					n = 1;
				}
				cards[i] = new Card(m, n);
			}

			selected = new Card[5];
			res = 0;
			combi(0, 0);

			String[] resStr = { &quot;Top&quot;, &quot;1 Pair&quot;, &quot;2 Pair&quot;, &quot;Triple&quot;, &quot;Straight&quot;, &quot;Flush&quot;, &quot;Full House&quot;, &quot;4 Card&quot;,
					&quot;Straight Flush&quot; };
			sb.append(&quot;#&quot;).append(test_case).append(&quot; &quot;).append(resStr[res]).append(&quot;\n&quot;);
		}
		sb.setLength(sb.length() - 1);
		System.out.println(sb);
	}

	public static void combi(int cnt, int idx) {
		if (cnt == 5) {
			poker();
			return;
		}

		for (int i = idx; i &amp;lt; 7; i++) {
			selected[cnt] = cards[i];
			combi(cnt + 1, i + 1);
		}
	}

	public static void poker() {
		int[] nCnt = new int[14];
		int[] mCnt = new int[4];

		for (int i = 0; i &amp;lt; 5; i++) {
			if (selected[i].m == 'S')
				mCnt[0]++;
			else if (selected[i].m == 'D')
				mCnt[1]++;
			else if (selected[i].m == 'C')
				mCnt[2]++;
			else if (selected[i].m == 'H')
				mCnt[3]++;

			nCnt[selected[i].n - 1]++;
			if (selected[i].n == 1) {
				nCnt[13]++;
			}

		}
		int Pair = 0;
		int Triple = 0;
		int Card4 = 0;
		boolean isStraight = false;
		// 연속되는지 확인
		for (int i = 0; i &amp;lt; 10; i++) {
			if (nCnt[i] == 0)
				continue;
			boolean c = true;
			for (int j = i + 1; j &amp;lt; i + 5; j++) {
				if (nCnt[j] == 0) {
					c = false;
					break;
				}
			}
			if (c) {
				isStraight = true;
				break;
			}
			if (nCnt[i] == 2)
				Pair++;
			else if (nCnt[i] == 3)
				Triple++;
			else if(nCnt[i]==4)
				Card4++;
		}

		for (int i = 10; i &amp;lt; 13; i++) {
			if (nCnt[i] == 2)
				Pair++;
			else if (nCnt[i] == 3)
				Triple++;
			else if(nCnt[i]==4)
				Card4++;
		}

		if (isStraight) {
			// 4. Straight
			res = res &amp;lt; 4 ? 4 : res;
		}

		if (mCnt[0] == 5 || mCnt[1] == 5 || mCnt[2] == 5 || mCnt[3] == 5) {
			if (isStraight) {
				// 8. Straight Flush
				res = 8;
				return;
			}
			// 5. Flush
			res = res &amp;lt; 5 ? 5 : res;
		}

		if (Pair &amp;gt; 0 &amp;amp;&amp;amp; Triple &amp;gt; 0) {
			// 6. Full House
			res = res &amp;lt; 6 ? 6 : res;
		} else if (Pair == 2) {
			// 2. 2 Pair
			res = res &amp;lt; 2 ? 2 : res;
		} else if (Pair == 1) {
			// 1. 1 Pair
			res = res &amp;lt; 1 ? 1 : res;
		} else if (Triple == 1) {
			// 3. Triple
			res = res &amp;lt; 3 ? 3 : res;
		} else if(Card4 == 1) {
			// 7. 4 card
			res = res&amp;lt; 7? 7:res;
		}
	}
}

class Card {
	char m;
	int n;

	public Card(char m, int n) {
		super();
		this.m = m;
		this.n = n;
	}
}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>Coding - Algo/Java</category>
      <category>3996 자바</category>
      <category>poker</category>
      <category>poker swea</category>
      <category>SWEA</category>
      <author>jainn</author>
      <guid isPermaLink="true">https://jainn.tistory.com/389</guid>
      <comments>https://jainn.tistory.com/389#entry389comment</comments>
      <pubDate>Tue, 29 Mar 2022 16:41:55 +0900</pubDate>
    </item>
    <item>
      <title>[SWEA] 4070:타일링(Java 자바)</title>
      <link>https://jainn.tistory.com/388</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;풀이 및 소스코드&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;BigInteger 처음 써 본 문제!&lt;/p&gt;
&lt;pre id=&quot;code_1648167865811&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.StringTokenizer;

class Solution {
	public static final int INF = 10000000;

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

		int T = Integer.parseInt(br.readLine());
		BigInteger[] dp = new BigInteger[251];
		dp[1] = new BigInteger(&quot;1&quot;);
		dp[2] = new BigInteger(&quot;3&quot;);
		int nowN = 3;

		for (int test_case = 1; test_case &amp;lt;= T; test_case++) {
			int n = Integer.parseInt(br.readLine());
			if(nowN&amp;lt;=n) {
				for(int i=nowN;i&amp;lt;=n;i++) {
					dp[i] = dp[i-2].multiply(new BigInteger(&quot;2&quot;));
					dp[i] = dp[i].add(dp[i-1]);
				}
				nowN = n;
			}
			sb.append(&quot;#&quot;).append(test_case).append(&quot; &quot;).append(dp[n]).append(&quot;\n&quot;);
		}
		sb.setLength(sb.length() - 1);
		System.out.println(sb);
	}

}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>Coding - Algo/Java</category>
      <category>swea 4070 타일링</category>
      <category>swea 타일링</category>
      <category>swea 타일링 자바</category>
      <category>타일링 자바</category>
      <author>jainn</author>
      <guid isPermaLink="true">https://jainn.tistory.com/388</guid>
      <comments>https://jainn.tistory.com/388#entry388comment</comments>
      <pubDate>Fri, 25 Mar 2022 09:24:58 +0900</pubDate>
    </item>
    <item>
      <title>[SWEA] 4066:All Pair Shortest Path(Java 자바)</title>
      <link>https://jainn.tistory.com/387</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;풀이 및 소스코드&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;플로이드 와샬 사용 !!&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre id=&quot;code_1648167051134&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Solution {
	public static final int INF = 10000000;

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

		int T = Integer.parseInt(br.readLine());

		for (int test_case = 1; test_case &amp;lt;= T; test_case++) {
			st = new StringTokenizer(br.readLine());
			int n = Integer.parseInt(st.nextToken());
			int m = Integer.parseInt(st.nextToken());
			int[][] dist = new int[n + 1][n + 1];
			for (int i = 1; i &amp;lt;= n; i++) {
				for (int j = 1; j &amp;lt;= n; j++) {
					if (i != j)
						dist[i][j] = INF;
				}
			}
			for (int i = 0; i &amp;lt; m; i++) {
				st = new StringTokenizer(br.readLine());
				int a = Integer.parseInt(st.nextToken());
				int b = Integer.parseInt(st.nextToken());
				int c = Integer.parseInt(st.nextToken());
				dist[a][b] = dist[a][b] &amp;gt; c ? c : dist[a][b];
			}

			for (int k = 1; k &amp;lt;= n; k++) {
				for (int i = 1; i &amp;lt;= n; i++) {
					for (int j = 1; j &amp;lt;= n; j++) {
						dist[i][j] = dist[i][j] &amp;gt; dist[i][k] + dist[k][j] ? dist[i][k] + dist[k][j] : dist[i][j];
					}
				}
			}
			sb.append(&quot;#&quot;).append(test_case).append(&quot; &quot;);
			for(int i=1;i&amp;lt;=n;i++) {
				for(int j=1;j&amp;lt;=n;j++) {
					if(i==j) sb.append(&quot;0 &quot;);
					else if (dist[i][j]&amp;gt;=INF) sb.append(&quot;-1 &quot;);
					else sb.append(dist[i][j]+&quot; &quot;);
				}
			}
			sb.append(&quot;\n&quot;);
		}
		sb.setLength(sb.length() - 1);
		System.out.println(sb);
	}

}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>Coding - Algo/Java</category>
      <category>swea 4066</category>
      <category>swea 4066 자바</category>
      <author>jainn</author>
      <guid isPermaLink="true">https://jainn.tistory.com/387</guid>
      <comments>https://jainn.tistory.com/387#entry387comment</comments>
      <pubDate>Fri, 25 Mar 2022 09:11:09 +0900</pubDate>
    </item>
    <item>
      <title>[SWEA] 4062:Largest Empty Square(Java 자바)</title>
      <link>https://jainn.tistory.com/386</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;0으로 입력된 것은 1로, 1로 입력된 것은 0으로 바꿔 map 배열에 넣는다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;dp[0][i] 와 dp[i][0] 에는 모두 자기 자리 값을 넣고 시작&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;대각선 위, 위, 왼쪽 비교 후 가장 최소값에 +1을 해주면 현재 좌표에서 만들 수 있는 제일 큰 정사각형 너비가 된다.&lt;/p&gt;
&lt;pre id=&quot;code_1647564390504&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

class Solution {
	public static void main(String args[]) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		StringTokenizer st;
		
		int T = Integer.parseInt(br.readLine());

		for (int test_case = 1; test_case &amp;lt;= T; test_case++) {
			int n = Integer.parseInt(br.readLine());
			char[][] map = new char[n][n];
			for(int i=0;i&amp;lt;n;i++) {
				map[i] = br.readLine().toCharArray();
				for(int j=0;j&amp;lt;n;j++) {
					map[i][j] = map[i][j]=='0' ? '1':'0';
				}
			}
			int[][] dp = new int[n][n];
			for(int i=0;i&amp;lt;n;i++) {
				dp[0][i] = map[0][i]-'0';
				dp[i][0] = map[i][0]-'0';
			}
			
			int res = 0;
			for(int i=1;i&amp;lt;n;i++) {
				for(int j=1;j&amp;lt;n;j++) {
					if(map[i][j]=='0') {
						dp[i][j] = 0;
						continue;
					}
					dp[i][j] = Math.min(dp[i-1][j], Math.min(dp[i-1][j-1], dp[i][j-1]))+1;
					res = dp[i][j] &amp;gt; res ? dp[i][j]	: res;
				}
			}
			sb.append(&quot;#&quot;).append(test_case).append(&quot; &quot;).append(res).append(&quot;\n&quot;);
		}
		sb.setLength(sb.length()-1);
		System.out.println(sb);
	}
}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>Coding - Algo/Java</category>
      <category>4062 자바</category>
      <category>Largest Empty Square</category>
      <author>jainn</author>
      <guid isPermaLink="true">https://jainn.tistory.com/386</guid>
      <comments>https://jainn.tistory.com/386#entry386comment</comments>
      <pubDate>Fri, 18 Mar 2022 09:46:57 +0900</pubDate>
    </item>
    <item>
      <title>[SWEA] 4052:프리랜서(Java 자바)</title>
      <link>https://jainn.tistory.com/385</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;1. 끝나는 시간 기준 오름차순 정렬&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;2. 끝나는 시간이 같다면 시작시간 기준 오름차순 정렬&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;3. 일정이 겹치기 바로 직전 일정 때의 cost + 현재 cost 값과 현재 일정을 하지 않았을 때 cost 둘 중 최대값을 dp 테이블에 넣는다.&lt;/p&gt;
&lt;pre id=&quot;code_1647563284944&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

class Solution {
	public static void main(String args[]) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		StringTokenizer st;
		
		int T = Integer.parseInt(br.readLine());

		for (int test_case = 1; test_case &amp;lt;= T; test_case++) {
			st = new StringTokenizer(br.readLine());
			int n = Integer.parseInt(st.nextToken());
			int m = Integer.parseInt(st.nextToken());
			
			Node[] info = new Node[n];
			for(int i=0;i&amp;lt;n;i++) {
				st = new StringTokenizer(br.readLine());
				int start = Integer.parseInt(st.nextToken());
				int end = Integer.parseInt(st.nextToken());
				int cost = Integer.parseInt(st.nextToken());
				info[i] = new Node(start, end, cost);
			}
			
			Arrays.sort(info);
			// 정렬
			
			int[] dp = new int[n];
			dp[0] = info[0].cost;
			
			for(int i=1;i&amp;lt;n;i++) {
				int idx = -1;
				for(int j=0;j&amp;lt;i;j++) {
					if(info[j].end &amp;gt;= info[i].start) {
						// 일정이 겹치면
						break;
					}
					idx = j;
				}
				
				int bCost = idx&amp;gt;=0 ? dp[idx] : 0;
				dp[i] = bCost+info[i].cost &amp;gt; dp[i-1] ? bCost+info[i].cost : dp[i-1];
			}
			
			int res = dp[n-1];
			sb.append(&quot;#&quot;).append(test_case).append(&quot; &quot;).append(res).append(&quot;\n&quot;);
		}
		sb.setLength(sb.length()-1);
		System.out.println(sb);
	}
}
class Node implements Comparable&amp;lt;Node&amp;gt;{
	int start,end,cost;

	public Node(int start, int end, int cost) {
		super();
		this.start = start;
		this.end = end;
		this.cost = cost;
	}

	@Override
	public int compareTo(Node o) {
		if(this.end==o.end) {
			// 끝나는 시간이 같다면 시작시간 기준 오름차순
			return this.start-o.start;
		}
		// 끝나는 시간기준 오름차순
		return this.end - o.end;
	}

	
}&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;</description>
      <category>Coding - Algo/Java</category>
      <author>jainn</author>
      <guid isPermaLink="true">https://jainn.tistory.com/385</guid>
      <comments>https://jainn.tistory.com/385#entry385comment</comments>
      <pubDate>Fri, 18 Mar 2022 09:29:01 +0900</pubDate>
    </item>
    <item>
      <title>[SWEA] 3819:최대 부분 배열(Java 자바)</title>
      <link>https://jainn.tistory.com/384</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;풀이 및 소스코드&lt;/p&gt;
&lt;pre id=&quot;code_1647527251580&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;import java.io.BufferedReader;
import java.io.InputStreamReader;

class Solution {
	public static void main(String args[]) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		int T = Integer.parseInt(br.readLine());

		for (int test_case = 1; test_case &amp;lt;= T; test_case++) {
			int res = -Integer.MAX_VALUE;
			
			int n = Integer.parseInt(br.readLine());
			
			int[] dp = new int[n+1];
			for(int i=1;i&amp;lt;n+1;i++) {
				int a = Integer.parseInt(br.readLine());
				dp[i] = Math.max(a, dp[i-1]+a);
				res = Math.max(dp[i], res);
			}
			
			sb.append(&quot;#&quot;).append(test_case).append(&quot; &quot;).append(res).append(&quot;\n&quot;);
		}
		sb.setLength(sb.length()-1);
		System.out.println(sb);
	}
}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>Coding - Algo/Java</category>
      <author>jainn</author>
      <guid isPermaLink="true">https://jainn.tistory.com/384</guid>
      <comments>https://jainn.tistory.com/384#entry384comment</comments>
      <pubDate>Thu, 17 Mar 2022 23:27:33 +0900</pubDate>
    </item>
    <item>
      <title>[SWEA] 3816:아나그램(Java 자바)</title>
      <link>https://jainn.tistory.com/383</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;풀이 및 소스코드&lt;/p&gt;
&lt;pre id=&quot;code_1647526675475&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;class UserSolution {
	public static int FindAnagram(int L1, String S1, int L2, String S2) {
		int res = 0;
		char[] arr1 = S1.toLowerCase().toCharArray();
		char[] arr2 = S2.toLowerCase().toCharArray();
		// 소문자로 통일시켜주기.

		int[] a1Alph = new int[26];
		
		int n = arr1.length;
		int n2 = arr2.length;
		
		for(int i=0;i&amp;lt;n;i++) {
			a1Alph[arr1[i]-'a']++;
		}
		

		for (int i = 0; i &amp;lt;= n2 - n; i++) {
			char[] tmp = Arrays.copyOfRange(arr2, i, i + n);

			int[] a2Alph = new int[26];
			for(int j=0;j&amp;lt;n;j++) {
				a2Alph[tmp[j]-'a']++;
			}
			
			
			boolean c = true;
			for (int j = 0; j &amp;lt; 26; j++) {
				if (a1Alph[j] != a2Alph[j]) {
					c = false;
					break;
				}
			}
			if (c)
				res++;
		}
		return res;
	}
}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>Coding - Algo/Java</category>
      <author>jainn</author>
      <guid isPermaLink="true">https://jainn.tistory.com/383</guid>
      <comments>https://jainn.tistory.com/383#entry383comment</comments>
      <pubDate>Thu, 17 Mar 2022 23:17:57 +0900</pubDate>
    </item>
    <item>
      <title>[SWEA] 3814:평등주의(Java 자바)</title>
      <link>https://jainn.tistory.com/382</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;풀이 및 소스코드&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;sb.setLength(sb.length()-1);&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;이거 안해주면 10개 틀렸다고 나온다. 이유는 ?? ㅜㅜ&lt;/p&gt;
&lt;pre id=&quot;code_1647500071898&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Solution {
	public static void main(String args[]) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		StringBuilder sb = new StringBuilder();

		int T = Integer.parseInt(br.readLine());

		for (int test_case = 1; test_case &amp;lt;= T; test_case++) {
			st = new StringTokenizer(br.readLine());
			int n = Integer.parseInt(st.nextToken());
			int k = Integer.parseInt(st.nextToken());

			int[] arr = new int[n];
			int max = 0;
			st = new StringTokenizer(br.readLine());
			for (int i = 0; i &amp;lt; n; i++) {
				arr[i] = Integer.parseInt(st.nextToken());
				max = max &amp;lt; arr[i] ? arr[i] : max;
			}

			int res = 0;

			int start = 0, end = max+1;
			
			outer: while (start &amp;lt; end) {
				int mid = (start + end) / 2;
				int[] tArr = arr.clone(); // 배열의 값을 수정해야하므로 temp배열 생성
				int subCnt = 0; // 뺀 값 넣기
				for (int i = 0; i &amp;lt; n - 1; i++) {
					// 뒤에꺼랑 비교해보기
					int sub = tArr[i + 1] - tArr[i];
					if (mid &amp;lt; sub) {
						// 설정해놓은 차이값 보다 크다면
						tArr[i + 1] -= (sub - mid);
						subCnt += (sub - mid);
					}
					if (subCnt &amp;gt; k) {
						start = mid + 1;
						res = start;
						continue outer;
					}
				}

				for (int i = n - 1; i &amp;gt; 0; i--) {
					// 앞에꺼랑 비교해보기
					int sub = tArr[i - 1] - tArr[i];
					if (mid &amp;lt; sub) {
						// 설정해놓은 차이값 보다 크다면
						tArr[i - 1] -= (sub - mid);
						subCnt += (sub - mid);
					}
					if (subCnt &amp;gt; k) {
						start = mid + 1;
						res = start;
						continue outer;
					}
				}
				end = mid;

			}
			sb.append(&quot;#&quot;).append(test_case).append(&quot; &quot;).append(res).append(&quot;\n&quot;);
		}
		sb.setLength(sb.length()-1);
		System.out.println(sb);
	}
}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>Coding - Algo/Java</category>
      <author>jainn</author>
      <guid isPermaLink="true">https://jainn.tistory.com/382</guid>
      <comments>https://jainn.tistory.com/382#entry382comment</comments>
      <pubDate>Thu, 17 Mar 2022 15:55:05 +0900</pubDate>
    </item>
    <item>
      <title>[SWEA] 3813:그래도 수명이 절반이 되어서는(Java 자바)</title>
      <link>https://jainn.tistory.com/381</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;풀이 및 소스코드&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;이진탐색을 통해 &lt;span style=&quot;background-color: #ffffff; color: #000000;&quot;&gt;Wear Level의 값을 찾아가면 된다.&lt;/span&gt;&lt;/p&gt;
&lt;pre id=&quot;code_1647435772049&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
class Solution
{
	public static void main(String args[]) throws Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		StringBuilder sb = new StringBuilder();
		
		int T = Integer.parseInt(br.readLine());
		int[] w;
		int[] s;
		
		for(int test_case = 1; test_case &amp;lt;= T; test_case++)
		{
			st = new StringTokenizer(br.readLine());
			int n = Integer.parseInt(st.nextToken());
			int k = Integer.parseInt(st.nextToken());
			
			w = new int[n];
			s = new int[k];
			
			st = new StringTokenizer(br.readLine());
			for(int i=0;i&amp;lt;n;i++) {
				w[i] = Integer.parseInt(st.nextToken());
			}
			
			st = new StringTokenizer(br.readLine());
			for(int i=0;i&amp;lt;k;i++) {
				s[i] = Integer.parseInt(st.nextToken());
			}
			
			int res=0;
			int start = 1, end = 200000;
			outer:while(start&amp;lt;end) {
				int mid = (start+end)/2;
				int cnt = 0;
				int idx = 0;
				for(int i=0;i&amp;lt;n;i++) {
					if(w[i]&amp;lt;=mid) {
						cnt++;
					}else {
						cnt = 0;
					}
					if(cnt == s[idx]) {
						idx++;
						cnt = 0;
					}
					if(idx&amp;gt;=k) {
						// 가능하면
						end = mid;
						res = end;
						continue outer;
					}
				}
				start = mid+1;
			}
			sb.append(&quot;#&quot;).append(test_case).append(&quot; &quot;).append(res).append(&quot;\n&quot;);
		}
		System.out.println(sb);
	}
}&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;​&lt;/p&gt;</description>
      <category>Coding - Algo/Java</category>
      <category>swea 3813</category>
      <category>swea 그래도 수명이 절반이 되어서는</category>
      <category>그래도 수명이 절반이 되어서는</category>
      <category>자바 그래도 수명이 절반이 되어서는</category>
      <author>jainn</author>
      <guid isPermaLink="true">https://jainn.tistory.com/381</guid>
      <comments>https://jainn.tistory.com/381#entry381comment</comments>
      <pubDate>Wed, 16 Mar 2022 22:03:11 +0900</pubDate>
    </item>
    <item>
      <title>[백준] 1300번:k번째 수(Java 자바)</title>
      <link>https://jainn.tistory.com/380</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;문제&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/1300&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://www.acmicpc.net/problem/1300&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1646720761778&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;1300번: K번째 수&quot; data-og-description=&quot;세준이는 크기가 N&amp;times;N인 배열 A를 만들었다. 배열에 들어있는 수&amp;nbsp;A[i][j] = i&amp;times;j 이다. 이 수를 일차원 배열 B에 넣으면 B의 크기는 N&amp;times;N이 된다. B를 오름차순 정렬했을 때, B[k]를&amp;nbsp;구해보자. 배열 A와 B&quot; data-og-host=&quot;www.acmicpc.net&quot; data-og-source-url=&quot;https://www.acmicpc.net/problem/1300&quot; data-og-url=&quot;https://www.acmicpc.net/problem/1300&quot; data-og-image=&quot;https://scrap.kakaocdn.net/dn/e9f34/hyNEgT7El1/4rmBWUOEfBXQ5x5RtGUyq0/img.png?width=2834&amp;amp;height=1480&amp;amp;face=0_0_2834_1480&quot;&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/1300&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-source-url=&quot;https://www.acmicpc.net/problem/1300&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url('https://scrap.kakaocdn.net/dn/e9f34/hyNEgT7El1/4rmBWUOEfBXQ5x5RtGUyq0/img.png?width=2834&amp;amp;height=1480&amp;amp;face=0_0_2834_1480');&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;1300번: K번째 수&lt;/p&gt;
&lt;p class=&quot;og-desc&quot; data-ke-size=&quot;size16&quot;&gt;세준이는 크기가 N&amp;times;N인 배열 A를 만들었다. 배열에 들어있는 수&amp;nbsp;A[i][j] = i&amp;times;j 이다. 이 수를 일차원 배열 B에 넣으면 B의 크기는 N&amp;times;N이 된다. B를 오름차순 정렬했을 때, B[k]를&amp;nbsp;구해보자. 배열 A와 B&lt;/p&gt;
&lt;p class=&quot;og-host&quot; data-ke-size=&quot;size16&quot;&gt;www.acmicpc.net&lt;/p&gt;
&lt;/div&gt;
&lt;/a&gt;&lt;/figure&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;풀이 및 소스코드&lt;/p&gt;
&lt;pre id=&quot;code_1646720768592&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		long n = Long.parseLong(br.readLine());
		long k = Long.parseLong(br.readLine());

		long start = 1;
		long end = k;

		while (start &amp;lt; end) {
			long mid = (start + end) / 2;
			long cnt = 0;

			for (int i = 1; i &amp;lt;= n; i++) {
				cnt += Math.min(mid / i, n);
			}
			if (k &amp;lt;= cnt) {
				end = mid;
			} else {
				start = mid + 1;
			}
		}
		System.out.println(start);
	}
}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>Coding - Algo/Java</category>
      <author>jainn</author>
      <guid isPermaLink="true">https://jainn.tistory.com/380</guid>
      <comments>https://jainn.tistory.com/380#entry380comment</comments>
      <pubDate>Tue, 8 Mar 2022 15:26:12 +0900</pubDate>
    </item>
  </channel>
</rss>