<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>CodeDrive</title>
    <link>https://codedrive.tistory.com/</link>
    <description>딥러닝 개발자가 되고 싶은 CodeDrive의 개발일지입니다.
</description>
    <language>ko</language>
    <pubDate>Fri, 8 May 2026 11:00:27 +0900</pubDate>
    <generator>TISTORY</generator>
    <ttl>100</ttl>
    <managingEditor>Pycoder</managingEditor>
    <item>
      <title>[BOJ] 3759. KCPC</title>
      <link>https://codedrive.tistory.com/590</link>
      <description>&lt;h4 data-ke-size=&quot;size20&quot;&gt;문제:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;당신은 유명 프로그래밍 대회인 KCPC(Korean Collegiate Programming Contest)에 참가하고 있다. 이 대회에서 총 k개의 문제를 풀게 되는데, 어떤 문제에 대한 풀이를 서버에 제출하면 그 문제에 대해 0점에서 100점 사이의 점수를 얻는다. 풀이를 제출한 팀의 ID, 문제 번호, 점수가 서버의 로그에 제출되는 시간 순서대로 저장된다. 한 문제에 대한 풀이를 여러 번 제출할 수 있는데, 그 중 최고 점수가 그 문제에 대한 최종 점수가 된다. (만약 어떤 문제에 대해 풀이를 한번도 제출하지 않았으면 그 문제에 대한 최종 점수는 0점이다.)&lt;/p&gt;
&lt;p style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot; data-ke-size=&quot;size16&quot;&gt;당신 팀의 최종 점수는 각 문제에 대해 받은 점수의 총합이고, 당신의 순위는 (당신 팀보다 높은 점수를 받은 팀의 수)+1 이다.&amp;nbsp;&lt;/p&gt;
&lt;p style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot; data-ke-size=&quot;size16&quot;&gt;점수가 동일한 팀이 여럿 있을 수 있는데, 그 경우에는 다음 규칙에 의해서 순위가 정해진다.&amp;nbsp;&lt;/p&gt;
&lt;ol style=&quot;list-style-type: decimal; background-color: #ffffff; color: #333333; text-align: start;&quot; data-ke-list-type=&quot;decimal&quot;&gt;
&lt;li style=&quot;color: #555555;&quot;&gt;최종 점수가 같은 경우, 풀이를 제출한 횟수가 적은 팀의 순위가 높다.&amp;nbsp;&lt;/li&gt;
&lt;li style=&quot;color: #555555;&quot;&gt;최종 점수도 같고 제출 횟수도 같은 경우, 마지막 제출 시간이 더 빠른 팀의 순위가 높다.&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;
&lt;p style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot; data-ke-size=&quot;size16&quot;&gt;동시에 제출되는 풀이는 없고, 모든 팀이 적어도 한 번은 풀이를 제출한다고 가정하라.&amp;nbsp;&lt;/p&gt;
&lt;p style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot; data-ke-size=&quot;size16&quot;&gt;서버의 로그가 주어졌을 때, 당신 팀의 순위를 계산하는 프로그램을 작성하시오.&lt;/p&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;입력:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;span style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot;&gt;입력 데이터는 표준 입력을 사용한다. 입력은 T개의 테스트 데이터로 구성된다. 입력의 첫 번째 줄에는 테스트 데이터의 수를 나타내는 정수 T가 주어진다. 각 테스트 데이터의 첫 번째 줄에는 팀의 개수 n, 문제의 개수 k, 당신 팀의 ID t, 로그 엔트리의 개수 m을 나타내는 4 개의 정수가 주어진다. 여기서, 3 &amp;le; n, k &amp;le; 100, 1 &amp;le; t &amp;le; n, 3 &amp;le; m &amp;le; 10,000이다. 그 다음 m개의 줄에는 각 풀이에 대한 정보가 제출되는 순서대로 주어진다. 각 줄에는 팀 ID i, 문제 번호 j, 획득한 점수 s를 나타내는 세 개의 정수가 주어진다. 여기서 1 &amp;le; i &amp;le; n, 1 &amp;le; j &amp;le; k, 0 &amp;le; s &amp;le; 100이다.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;출력:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;span style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot;&gt;출력은 표준출력을 사용한다. 주어진 각 테스트 데이터에 대해 당신 팀의 순위를 한 줄에 출력하여야 한다&lt;/span&gt;&lt;/p&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;풀이방법:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;주어지는 로그 엔트리들을 팀 ID, 문제 번호대로 정리를 잘 하고, 주어진 조건에 따라서 정렬을 하면 되는 문제다. 따라서 입력을 받을 당시에 defaultdict을 사용하여 raw 데이터를 저장하고, 이 와 동시에 가장 큰 점수와 마지막 인덱스도 저장하도록 한다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;raw 데이터들은 Counter를 통해 빈도를 계산하며 이를 통합하여 정렬하도록 한다.&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position: relative !important; overflow: auto;&quot;&gt;
&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin: 0; padding: 0; border: none; background-color: #272727; border-radius: 4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;padding: 6px; border-right: 2px solid #4f4f4f;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; word-break: normal; text-align: right; color: #aaa; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;1&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;2&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;3&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;4&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;5&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;6&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;7&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;8&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;9&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;10&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;11&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;12&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;13&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;14&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;15&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;16&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;17&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;18&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;19&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;20&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;21&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;22&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;23&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;24&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;25&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;26&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;27&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;28&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;29&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;30&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;padding: 6px 0; text-align: left;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;from&lt;/span&gt;&amp;nbsp;collections&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;import&lt;/span&gt;&amp;nbsp;defaultdict,&amp;nbsp;Counter&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;T&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;(input())&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;_&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;range&lt;/span&gt;(T):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;n,&amp;nbsp;k,&amp;nbsp;t,&amp;nbsp;m&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;map(&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;,&amp;nbsp;input().split())&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;score&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;dict()&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;n&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;score[i]&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;defaultdict(&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;)&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;elements&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;[]&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;last_index&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;defaultdict(&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;)&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;idx&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;range&lt;/span&gt;(m):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;i,&amp;nbsp;j,&amp;nbsp;s&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;map(&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;,&amp;nbsp;input().split())&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;elements.append(i)&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;score[i][j]&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;max(score[i][j],&amp;nbsp;s)&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;last_index[i]&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;idx&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;element_count&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;Counter(elements)&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;total_score&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;[]&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;n&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;total_score.append((i,&amp;nbsp;sum(score[i].values()),&amp;nbsp;element_count[i],&amp;nbsp;last_index[i]))&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;total_score&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;sorted(total_score,&amp;nbsp;key&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;lambda&amp;nbsp;x:&amp;nbsp;(&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;x[&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;],&amp;nbsp;x[&lt;span style=&quot;color: #c10aff;&quot;&gt;2&lt;/span&gt;],&amp;nbsp;x[&lt;span style=&quot;color: #c10aff;&quot;&gt;3&lt;/span&gt;]))&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i,&amp;nbsp;_,&amp;nbsp;_,&amp;nbsp;_&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;total_score:&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;i&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;t:&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;print&lt;/span&gt;(answer&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;)&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: right; margin-top: -13px; margin-right: 5px; font-size: 9px; font-style: italic;&quot;&gt;&lt;a style=&quot;color: #4f4f4ftext-decoration:none;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;vertical-align: bottom; padding: 0 2px 4px 0;&quot;&gt;&lt;a style=&quot;text-decoration: none; color: white;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: #4f4f4f; color: white; border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;문제링크:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/3758&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://www.acmicpc.net/problem/3758&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1690176230258&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;3758번: KCPC&quot; data-og-description=&quot;입력 데이터는 표준 입력을 사용한다. 입력은 T개의 테스트 데이터로 구성된다. 입력의 첫 번째 줄에는 테스트 데이터의 수를 나타내는 정수 T가 주어진다. 각 테스트 데이터의 첫 번째 줄에는 &quot; data-og-host=&quot;www.acmicpc.net&quot; data-og-source-url=&quot;https://www.acmicpc.net/problem/3758&quot; data-og-url=&quot;https://www.acmicpc.net/problem/3758&quot; data-og-image=&quot;https://scrap.kakaocdn.net/dn/DXUym/hyTo3CIDxI/jV9CksPdJViRKcPhXnB3G1/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/3758&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-source-url=&quot;https://www.acmicpc.net/problem/3758&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url('https://scrap.kakaocdn.net/dn/DXUym/hyTo3CIDxI/jV9CksPdJViRKcPhXnB3G1/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;3758번: KCPC&lt;/p&gt;
&lt;p class=&quot;og-desc&quot; data-ke-size=&quot;size16&quot;&gt;입력 데이터는 표준 입력을 사용한다. 입력은 T개의 테스트 데이터로 구성된다. 입력의 첫 번째 줄에는 테스트 데이터의 수를 나타내는 정수 T가 주어진다. 각 테스트 데이터의 첫 번째 줄에는&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;div id=&quot;__endic_crx__&quot;&gt;
&lt;div class=&quot;css-diqpy0&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;</description>
      <category>Algorithm/Python</category>
      <category>3758</category>
      <category>BOJ</category>
      <category>KCPC</category>
      <category>Python</category>
      <category>백준</category>
      <category>알고리즘</category>
      <category>정렬</category>
      <category>파이썬</category>
      <author>Pycoder</author>
      <guid isPermaLink="true">https://codedrive.tistory.com/590</guid>
      <comments>https://codedrive.tistory.com/590#entry590comment</comments>
      <pubDate>Mon, 31 Jul 2023 12:00:34 +0900</pubDate>
    </item>
    <item>
      <title>[BOJ] 19637. IF문 좀 대신 써줘</title>
      <link>https://codedrive.tistory.com/589</link>
      <description>&lt;h4 data-ke-size=&quot;size20&quot;&gt;문제:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;게임 개발자인 밀리는 전투력 시스템을 만들어, 캐릭터가 가진 전투력을 기준으로 칭호를 붙여주려고 한다.&lt;/p&gt;
&lt;p style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot; data-ke-size=&quot;size16&quot;&gt;예를 들어, 전투력 10,000 이하의 캐릭터는 WEAK, 10,000 초과 그리고 100,000 이하의 캐릭터는 NORMAL, 100,000 초과 그리고 1,000,000 이하의 캐릭터는 STRONG 칭호를 붙여준다고 하자. 이를 IF문으로 작성한다면 아래와 같이 구현할 수 있다.&lt;/p&gt;
&lt;pre class=&quot;gradle&quot; style=&quot;background-color: #f5f5f5; color: #333333; text-align: start;&quot;&gt;&lt;code&gt;if power &amp;lt;= 10000
 print WEAK
else if power &amp;lt;= 100000
 print NORMAL
else if power &amp;lt;= 1000000
 print STRONG&lt;/code&gt;&lt;/pre&gt;
&lt;p style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot; data-ke-size=&quot;size16&quot;&gt;혼자서 게임을 개발하느라 매우 바쁜 밀리를 대신해서, 캐릭터의 전투력에 맞는 칭호를 출력하는 프로그램을 작성하자.&lt;/p&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;입력:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;첫 번째 줄에는 칭호의 개수&amp;nbsp;N&amp;nbsp;(1&amp;nbsp;&amp;le;&amp;nbsp;N&amp;nbsp;&amp;le; 105)과&amp;nbsp;칭호를 출력해야 하는 캐릭터들의 개수&amp;nbsp;M&amp;nbsp;(1&amp;nbsp;&amp;le;&amp;nbsp;M&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;le; 105)이 빈칸을 사이에 두고 주어진다.&amp;nbsp;(1&amp;nbsp;&amp;le;&amp;nbsp;N, M&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;le; 105)&lt;/p&gt;
&lt;p style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot; data-ke-size=&quot;size16&quot;&gt;두 번째 줄부터&amp;nbsp;N개의 줄에 각 칭호의 이름을 나타내는 길이 1 이상, 11 이하의 영어 대문자로만 구성된 문자열과 해당 칭호의 전투력 상한값을 나타내는 109&amp;nbsp;이하의 음이 아닌 정수가&amp;nbsp;주어진다. 칭호는 전투력 상한값의 비내림차순으로 주어진다.&amp;nbsp;&lt;/p&gt;
&lt;p style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot; data-ke-size=&quot;size16&quot;&gt;N&amp;nbsp;+ 2번째 줄부터&amp;nbsp;M개의 각 줄에는 캐릭터의 전투력을 나타내는 음이 아닌 정수가&amp;nbsp;주어진다. 해당하는 칭호가 없는 전투력은&amp;nbsp;입력으로 주어지지 않는다.&lt;/p&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;출력:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;M&lt;span style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot;&gt;개의 줄에 걸쳐 캐릭터의 전투력에 맞는 칭호를 입력 순서대로 출력한다. 어떤 캐릭터의 전투력으로 출력할 수 있는 칭호가 여러 개인 경우 가장 먼저 입력된 칭호 하나만 출력한다.&lt;/span&gt;&lt;/p&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;풀이방법:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;N, M의 범위가 많이 크기 때문에 일반적인 탐색을 사용한다면 시간초과가 발생하게 된다. 따라서 더 빠른 탐색을 사용하여 이분탐색을 사용하도록 한다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;따라서 python에는 이분탐색을 도와주는 bisect가 있기 때문에 이를 사용할 수 있다. 이 문제는 이분 탐색을 수행하고, 주어진 M을 왼쪽에 삽입하는 것과 같기 때문에 bisect_left 함수를 사용하도록 한다. 주어진 M이 이분 탐색에 의해 삽입될 인덱스를 구하게 된다면, 그 인덱스에 해당하는 칭호의 이름을 출력하도록 한다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;그리고 출력 조건에서 칭호가 여러 개인 경우 가장 먼저 입력된 칭호 하나를 출력해야 하는데, 입력이 애초에 오름차순으로 주어지기 때문에 따로 고려할 점은 없다.&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position: relative !important; overflow: auto;&quot;&gt;
&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin: 0; padding: 0; border: none; background-color: #272727; border-radius: 4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;padding: 6px; border-right: 2px solid #4f4f4f;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; word-break: normal; text-align: right; color: #aaa; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;1&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;2&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;3&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;4&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;5&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;6&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;7&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;8&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;9&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;10&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;11&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;12&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;padding: 6px 0; text-align: left;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;import&lt;/span&gt;&amp;nbsp;bisect&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;N,&amp;nbsp;M&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;map(&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;,&amp;nbsp;input().split())&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;style,&amp;nbsp;number&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;[],&amp;nbsp;[]&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;_&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;range&lt;/span&gt;(N):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;s,&amp;nbsp;n&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;input().split()&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;style.append(s)&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;number.append(&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;(n))&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;_&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;range&lt;/span&gt;(M):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;m&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;(input())&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;print&lt;/span&gt;(style[bisect.bisect_left(number,&amp;nbsp;m)])&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;vertical-align: bottom; padding: 0 2px 4px 0;&quot;&gt;&lt;a style=&quot;text-decoration: none; color: white;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: #4f4f4f; color: white; border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;문제링크:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/19637&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://www.acmicpc.net/problem/19637&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1690175917423&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;19637번: IF문 좀 대신 써줘&quot; data-og-description=&quot;첫 번째 줄에는 칭호의 개수&amp;nbsp;N&amp;nbsp;(1&amp;nbsp;&amp;le;&amp;nbsp;N&amp;nbsp;&amp;le; 105)과&amp;nbsp;칭호를 출력해야 하는 캐릭터들의 개수&amp;nbsp;M&amp;nbsp;(1&amp;nbsp;&amp;le;&amp;nbsp;M &amp;le; 105)이 빈칸을 사이에 두고 주어진다.&amp;nbsp;(1&amp;nbsp;&amp;le;&amp;nbsp;N, M &amp;le; 105) 두 번째 줄부터&amp;nbsp;N개의 줄에 각 칭&quot; data-og-host=&quot;www.acmicpc.net&quot; data-og-source-url=&quot;https://www.acmicpc.net/problem/19637&quot; data-og-url=&quot;https://www.acmicpc.net/problem/19637&quot; data-og-image=&quot;https://scrap.kakaocdn.net/dn/pjPCh/hyTo9Qp7OE/XnvQVuki8nqQRYVY3flKvk/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/19637&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-source-url=&quot;https://www.acmicpc.net/problem/19637&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url('https://scrap.kakaocdn.net/dn/pjPCh/hyTo9Qp7OE/XnvQVuki8nqQRYVY3flKvk/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;19637번: IF문 좀 대신 써줘&lt;/p&gt;
&lt;p class=&quot;og-desc&quot; data-ke-size=&quot;size16&quot;&gt;첫 번째 줄에는 칭호의 개수&amp;nbsp;N&amp;nbsp;(1&amp;nbsp;&amp;le;&amp;nbsp;N&amp;nbsp;&amp;le; 105)과&amp;nbsp;칭호를 출력해야 하는 캐릭터들의 개수&amp;nbsp;M&amp;nbsp;(1&amp;nbsp;&amp;le;&amp;nbsp;M &amp;le; 105)이 빈칸을 사이에 두고 주어진다.&amp;nbsp;(1&amp;nbsp;&amp;le;&amp;nbsp;N, M &amp;le; 105) 두 번째 줄부터&amp;nbsp;N개의 줄에 각 칭&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;div id=&quot;__endic_crx__&quot;&gt;
&lt;div class=&quot;css-diqpy0&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;</description>
      <category>Algorithm/Python</category>
      <category>19637</category>
      <category>BOJ</category>
      <category>IF문 좀 대신 써줘</category>
      <category>Python</category>
      <category>백준</category>
      <category>알고리즘</category>
      <category>이분 탐색</category>
      <category>파이썬</category>
      <author>Pycoder</author>
      <guid isPermaLink="true">https://codedrive.tistory.com/589</guid>
      <comments>https://codedrive.tistory.com/589#entry589comment</comments>
      <pubDate>Fri, 28 Jul 2023 12:00:42 +0900</pubDate>
    </item>
    <item>
      <title>[Programmers] Lv 2. 점 찍기</title>
      <link>https://codedrive.tistory.com/588</link>
      <description>&lt;h4 data-ke-size=&quot;size20&quot;&gt;문제:&lt;/h4&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignCenter&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-origin-width=&quot;988&quot; data-origin-height=&quot;226&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/bH11j7/btsoNWsJErd/FGRFrgkM9tY5z2ticXCzjK/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/bH11j7/btsoNWsJErd/FGRFrgkM9tY5z2ticXCzjK/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/bH11j7/btsoNWsJErd/FGRFrgkM9tY5z2ticXCzjK/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbH11j7%2FbtsoNWsJErd%2FFGRFrgkM9tY5z2ticXCzjK%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;988&quot; height=&quot;226&quot; data-origin-width=&quot;988&quot; data-origin-height=&quot;226&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;풀이방법:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;원점과 거리가 모두 d인 위치라는 것은 원을 의미한다. 조건상으로는 1사분면에 있는 사분원 내의 정수 점을 찾으면 되는 문제다. x와 y를 모두 변경하면서 조건을 만족하는 점을 찾는 방법을 사용할 수 있지만, 시간초과가 발생하게 된다. 따라서 x를 먼저 결정하고 피타고라스 정리를 사용하여 최대 길이의 y를 찾아 가능한 경우의 수를 모두 찾도록 한다.&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position: relative !important; overflow: auto;&quot;&gt;
&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin: 0; padding: 0; border: none; background-color: #272727; border-radius: 4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;padding: 6px; border-right: 2px solid #4f4f4f;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; word-break: normal; text-align: right; color: #aaa; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;1&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;2&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;3&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;4&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;5&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;6&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;7&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;padding: 6px 0; text-align: left;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;import&lt;/span&gt;&amp;nbsp;math&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;def&lt;/span&gt;&amp;nbsp;solution(k,&amp;nbsp;d):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;x&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;d&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;k):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;y&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;math.floor(math.sqrt(d&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;x&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;2&lt;/span&gt;))&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;y&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;/&lt;/span&gt;k&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;return&lt;/span&gt;&amp;nbsp;answer&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;vertical-align: bottom; padding: 0 2px 4px 0;&quot;&gt;&lt;a style=&quot;text-decoration: none; color: white;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: #4f4f4f; color: white; border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;문제링크:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a href=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/140107&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://school.programmers.co.kr/learn/courses/30/lessons/140107&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1690174993846&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/140107&quot; data-og-url=&quot;https://programmers.co.kr/&quot; data-og-image=&quot;https://scrap.kakaocdn.net/dn/C5Nnn/hyTqAeyEyl/ZtSzKztr4G6lkERFNMSwuk/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/cTAjVf/hyTpa9FcfV/CDIWTic2c5XvUwpsUVxz10/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/140107&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-source-url=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/140107&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url('https://scrap.kakaocdn.net/dn/C5Nnn/hyTqAeyEyl/ZtSzKztr4G6lkERFNMSwuk/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/cTAjVf/hyTpa9FcfV/CDIWTic2c5XvUwpsUVxz10/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;div id=&quot;__endic_crx__&quot;&gt;
&lt;div class=&quot;css-diqpy0&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;</description>
      <category>Algorithm/Python</category>
      <category>programmers</category>
      <category>Python</category>
      <category>기하학</category>
      <category>수학</category>
      <category>알고리즘</category>
      <category>점 찍기</category>
      <category>파이썬</category>
      <category>프로그래머스</category>
      <author>Pycoder</author>
      <guid isPermaLink="true">https://codedrive.tistory.com/588</guid>
      <comments>https://codedrive.tistory.com/588#entry588comment</comments>
      <pubDate>Thu, 27 Jul 2023 12:00:22 +0900</pubDate>
    </item>
    <item>
      <title>[BOJ] 2607. 비슷한 단어</title>
      <link>https://codedrive.tistory.com/587</link>
      <description>&lt;h4 data-ke-size=&quot;size20&quot;&gt;문제:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;영문 알파벳 대문자로 이루어진 두 단어가 다음의 두 가지 조건을 만족하면 같은 구성을 갖는다고 말한다.&lt;/p&gt;
&lt;ol style=&quot;list-style-type: decimal; background-color: #ffffff; color: #333333; text-align: start;&quot; data-ke-list-type=&quot;decimal&quot;&gt;
&lt;li style=&quot;color: #555555;&quot;&gt;두 개의 단어가 같은 종류의 문자로 이루어져 있다.&lt;/li&gt;
&lt;li style=&quot;color: #555555;&quot;&gt;같은 문자는 같은 개수 만큼 있다.&lt;/li&gt;
&lt;/ol&gt;
&lt;p style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot; data-ke-size=&quot;size16&quot;&gt;예를 들어 &quot;DOG&quot;와 &quot;GOD&quot;은 둘 다 'D', 'G', 'O' 세 종류의 문자로 이루어져 있으며 양쪽 모두 'D', 'G', 'O' 가 하나씩 있으므로 이 둘은 같은 구성을 갖는다. 하지만 &quot;GOD&quot;과 &quot;GOOD&quot;의 경우 &quot;GOD&quot;에는 'O'가 하나, &quot;GOOD&quot;에는 'O'가 두 개 있으므로 이 둘은 다른 구성을 갖는다.&lt;/p&gt;
&lt;p style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot; data-ke-size=&quot;size16&quot;&gt;두 단어가 같은 구성을 갖는 경우, 또는 한 단어에서 한 문자를 더하거나, 빼거나, 하나의 문자를 다른 문자로 바꾸어 나머지 한 단어와 같은 구성을 갖게 되는 경우에 이들 두 단어를 서로 비슷한 단어라고 한다.&lt;/p&gt;
&lt;p style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot; data-ke-size=&quot;size16&quot;&gt;예를 들어 &quot;DOG&quot;와 &quot;GOD&quot;은 같은 구성을 가지므로 이 둘은 비슷한 단어이다. 또한 &quot;GOD&quot;에서 'O'를 하나 추가하면 &quot;GOOD&quot; 과 같은 구성을 갖게 되므로 이 둘 또한 비슷한 단어이다. 하지만 &quot;DOG&quot;에서 하나의 문자를 더하거나, 빼거나, 바꾸어도 &quot;DOLL&quot;과 같은 구성이 되지는 않으므로 &quot;DOG&quot;과 &quot;DOLL&quot;은 비슷한 단어가 아니다.&lt;/p&gt;
&lt;p style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot; data-ke-size=&quot;size16&quot;&gt;입력으로 여러 개의 서로 다른 단어가 주어질 때, 첫 번째 단어와 비슷한 단어가 모두 몇 개인지 찾아 출력하는 프로그램을 작성하시오.&lt;/p&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;입력:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;span style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot;&gt;첫째 줄에는 단어의 개수가 주어지고 둘째 줄부터는 한 줄에 하나씩 단어가 주어진다. 모든 단어는 영문 알파벳 대문자로 이루어져 있다. 단어의 개수는 100개 이하이며, 각 단어의 길이는 10 이하이다.&lt;/span&gt;&lt;/p&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;출력:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;span style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot;&gt;입력으로 주어진 첫 번째 단어와 비슷한 단어가 몇 개인지 첫째 줄에&amp;nbsp;출력한다.&lt;/span&gt;&lt;/p&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;풀이방법:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;주어진 경우의 수가 많지 않기 때문에 모든 경우의 수에 대해 고려하도록 한다. main으로 선택한 단어는 비교할 단어가 들어올 때마다 복사해서 사용한다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;main 단어와 비교할 단어를 비교하면서 문자가 겹치는 것이 있는지 확인한다. 겹치는 문자가 있다면 remove를 하고 없다면 count를 증가시킨다. 모든 비교를 완료한 뒤에 count가 1 이하, 남은 단어가 1 이하인지 확인하도록 한다. 만약 각 값들이 2보다 크다면 '&lt;span style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot;&gt;&lt;b&gt;한 문자를 더하거나, 빼거나, 하나의 문자를 다른 문자로 바꾸어&lt;/b&gt;' 조건에 해당하지 않게 된다.&lt;/span&gt;&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position: relative !important; overflow: auto;&quot;&gt;
&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin: 0; padding: 0; border: none; background-color: #272727; border-radius: 4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;padding: 6px; border-right: 2px solid #4f4f4f;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; word-break: normal; text-align: right; color: #aaa; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;1&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;2&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;3&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;4&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;5&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;6&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;7&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;8&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;9&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;10&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;11&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;12&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;13&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;14&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;15&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;16&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;17&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;18&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;19&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;20&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;21&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;padding: 6px 0; text-align: left;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;N&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;(input())&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;words&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;[]&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;_&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;range&lt;/span&gt;(N):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;words.append(input())&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;main_word&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;words[&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;]&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;answer&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;word&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;words[&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;:]:&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;target&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;list(main_word)&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;count&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;w&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;word:&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;w&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;target:&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;target.remove(w)&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;else&lt;/span&gt;:&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;count&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;count&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;2&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;and&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;len&lt;/span&gt;(target)&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;2&lt;/span&gt;:&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;print&lt;/span&gt;(answer)&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;vertical-align: bottom; padding: 0 2px 4px 0;&quot;&gt;&lt;a style=&quot;text-decoration: none; color: white;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: #4f4f4f; color: white; border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;문제링크:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/2607&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://www.acmicpc.net/problem/2607&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1689645695933&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;2607번: 비슷한 단어&quot; data-og-description=&quot;첫째 줄에는 단어의 개수가 주어지고 둘째 줄부터는 한 줄에 하나씩 단어가 주어진다. 모든 단어는 영문 알파벳 대문자로 이루어져 있다. 단어의 개수는 100개 이하이며, 각 단어의 길이는 10 이&quot; data-og-host=&quot;www.acmicpc.net&quot; data-og-source-url=&quot;https://www.acmicpc.net/problem/2607&quot; data-og-url=&quot;https://www.acmicpc.net/problem/2607&quot; data-og-image=&quot;https://scrap.kakaocdn.net/dn/c8avxc/hyTlaIO7kI/OdsvnG1nkO6Lt3oK8lykvK/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/2607&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-source-url=&quot;https://www.acmicpc.net/problem/2607&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url('https://scrap.kakaocdn.net/dn/c8avxc/hyTlaIO7kI/OdsvnG1nkO6Lt3oK8lykvK/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;2607번: 비슷한 단어&lt;/p&gt;
&lt;p class=&quot;og-desc&quot; data-ke-size=&quot;size16&quot;&gt;첫째 줄에는 단어의 개수가 주어지고 둘째 줄부터는 한 줄에 하나씩 단어가 주어진다. 모든 단어는 영문 알파벳 대문자로 이루어져 있다. 단어의 개수는 100개 이하이며, 각 단어의 길이는 10 이&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;div id=&quot;__endic_crx__&quot;&gt;
&lt;div class=&quot;css-diqpy0&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;</description>
      <category>Algorithm/Python</category>
      <category>2607</category>
      <category>BOJ</category>
      <category>Python</category>
      <category>문자열</category>
      <category>백준</category>
      <category>브루트 포스</category>
      <category>비슷한 단어</category>
      <category>알고리즘</category>
      <category>파이썬</category>
      <author>Pycoder</author>
      <guid isPermaLink="true">https://codedrive.tistory.com/587</guid>
      <comments>https://codedrive.tistory.com/587#entry587comment</comments>
      <pubDate>Wed, 26 Jul 2023 12:00:41 +0900</pubDate>
    </item>
    <item>
      <title>[Programmers]Lv 2. 호텔 대실</title>
      <link>https://codedrive.tistory.com/586</link>
      <description>&lt;h4 data-ke-size=&quot;size20&quot;&gt;문제:&lt;/h4&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignCenter&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-origin-width=&quot;973&quot; data-origin-height=&quot;113&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/YIy3X/btsnYYeRmu7/P9KL4IiuaI3GR7G6CNjMU0/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/YIy3X/btsnYYeRmu7/P9KL4IiuaI3GR7G6CNjMU0/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/YIy3X/btsnYYeRmu7/P9KL4IiuaI3GR7G6CNjMU0/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FYIy3X%2FbtsnYYeRmu7%2FP9KL4IiuaI3GR7G6CNjMU0%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;973&quot; height=&quot;113&quot; data-origin-width=&quot;973&quot; data-origin-height=&quot;113&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;풀이방법:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;시간은 한정되어 있기 때문에 모든 케이스를 다 고려하는 방법으로 문제를 해결했다. 최대로 필요한 객실의 수는 입력으로 들어오는 book_time의 길이와 같다. 따라서 book_time의 높이와 시간의 길이를 가지는 배열(hotel)을 만들도록 한다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;그리고 각 예약 손님이 사용하는 길이를 hotel 배열에 기록한다. 이 때, 10분간 청소를 하는 시간 또한 같이 고려하도록 한다. 모든 예약 손님에 대해 기록을 완료했다면 세로로 hotel 배열을 탐색하며 가장 많이 겹치는 구간을 답으로 선정한다.&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position: relative !important; overflow: auto;&quot;&gt;
&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin: 0; padding: 0; border: none; background-color: #272727; border-radius: 4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;padding: 6px; border-right: 2px solid #4f4f4f;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; word-break: normal; text-align: right; color: #aaa; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;1&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;2&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;3&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;4&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;5&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;6&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;7&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;8&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;9&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;10&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;11&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;12&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;13&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;14&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;15&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;16&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;17&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;18&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;19&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;20&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;21&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;22&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;23&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;24&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;25&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;26&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;27&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;padding: 6px 0; text-align: left;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;def&lt;/span&gt;&amp;nbsp;convert_time(tm):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;hh,&amp;nbsp;mm&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;map(&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;,&amp;nbsp;tm.split(&lt;span style=&quot;color: #ffd500;&quot;&gt;&quot;:&quot;&lt;/span&gt;))&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;return&lt;/span&gt;&amp;nbsp;hh&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;60&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&amp;nbsp;mm&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;def&lt;/span&gt;&amp;nbsp;solution(book_time):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;book_time&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;sorted(book_time)&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;hotel&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;[[&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;_&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #c10aff;&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;24&lt;/span&gt;)]&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;_&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #4be6fa;&quot;&gt;len&lt;/span&gt;(book_time))]&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i,&amp;nbsp;bt&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;enumerate(book_time):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;st,&amp;nbsp;et&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;bt&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;st&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;convert_time(st)&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;et&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;convert_time(et)&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;t&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;range&lt;/span&gt;(st,&amp;nbsp;et&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;10&lt;/span&gt;):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;t&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;24&lt;/span&gt;:&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;hotel[i][t]&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #c10aff;&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;24&lt;/span&gt;):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;count&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #4be6fa;&quot;&gt;len&lt;/span&gt;(book_time)):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;count&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;hotel[j][i]&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;max(answer,&amp;nbsp;count)&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;return&lt;/span&gt;&amp;nbsp;answer&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: right; margin-top: -13px; margin-right: 5px; font-size: 9px; font-style: italic;&quot;&gt;&lt;a style=&quot;color: #4f4f4ftext-decoration:none;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;vertical-align: bottom; padding: 0 2px 4px 0;&quot;&gt;&lt;a style=&quot;text-decoration: none; color: white;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: #4f4f4f; color: white; border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;문제링크:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a href=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/155651&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://school.programmers.co.kr/learn/courses/30/lessons/155651&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1689644532461&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/155651&quot; data-og-url=&quot;https://programmers.co.kr/&quot; data-og-image=&quot;https://scrap.kakaocdn.net/dn/cjENwu/hyTmn0O8SW/P4yzw19hHkKQqWk9x62QuK/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/f0IhA/hyTk51MiJm/Kyw7KpEII91LwTXkFIfKp0/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/155651&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-source-url=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/155651&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url('https://scrap.kakaocdn.net/dn/cjENwu/hyTmn0O8SW/P4yzw19hHkKQqWk9x62QuK/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/f0IhA/hyTk51MiJm/Kyw7KpEII91LwTXkFIfKp0/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;div id=&quot;__endic_crx__&quot;&gt;
&lt;div class=&quot;css-diqpy0&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;</description>
      <category>Algorithm/Python</category>
      <category>BOJ</category>
      <category>Python</category>
      <category>구현</category>
      <category>백준</category>
      <category>브루트 포스</category>
      <category>알고리즘</category>
      <category>파이썬</category>
      <category>프로그래머스</category>
      <category>호텔 대실</category>
      <author>Pycoder</author>
      <guid isPermaLink="true">https://codedrive.tistory.com/586</guid>
      <comments>https://codedrive.tistory.com/586#entry586comment</comments>
      <pubDate>Tue, 25 Jul 2023 12:00:51 +0900</pubDate>
    </item>
    <item>
      <title>[BOJ] 1515. 수 이어 쓰기</title>
      <link>https://codedrive.tistory.com/585</link>
      <description>&lt;h4 data-ke-size=&quot;size20&quot;&gt;문제:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;세준이는 1부터 N까지 모든 수를 차례대로 공백없이 한 줄에 다 썼다. 그리고 나서, 세준이가 저녁을 먹으러 나간 사이에 다솜이는 세준이가 쓴 수에서&amp;nbsp;마음에 드는 몇 개의 숫자를 지웠다.&lt;/p&gt;
&lt;p style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot; data-ke-size=&quot;size16&quot;&gt;세준이는 저녁을 먹으러 갔다 와서, 자기가 쓴 수의 일부가 지워져있는 모습을 보고 충격받았다.&lt;/p&gt;
&lt;p style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot; data-ke-size=&quot;size16&quot;&gt;세준이는 수를 방금 전과 똑같이 쓰려고 한다. 하지만, N이 기억이 나지 않는다.&lt;/p&gt;
&lt;p style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot; data-ke-size=&quot;size16&quot;&gt;남은 수를 이어 붙인 수가 주어질 때, N의 최솟값을 구하는 프로그램을 작성하시오. 아무것도 지우지 않을 수도 있다.)&lt;/p&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;입력:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;span style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot;&gt;첫째 줄에 지우고 남은 수를 한 줄로 이어 붙인 수가 주어진다. 이 수는 최대 3,000자리다.&lt;/span&gt;&lt;/p&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;출력:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;span style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot;&gt;가능한 N 중에 최솟값을 출력한다.&lt;/span&gt;&lt;/p&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;풀이방법:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;원래 세준이가 쓴 숫자는 다음과 같을 것이다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;b&gt;12345678910111213141516....&lt;/b&gt;&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;p data-ke-size=&quot;size16&quot;&gt;즉, 234092와 같은 경우에는 1&lt;b&gt;234&lt;/b&gt;56789&lt;b&gt;10&lt;/b&gt;1112131415161718&lt;b&gt;1920 &lt;/b&gt;중 굵은 숫자의 일부분이 남은 것과 같다. 1부터 하나씩 증가하면서 234092와 비교한다. 2,3,4 에서는 바로 일치되긴 하지만 10부터는 바로 일치되지 않을 것이다. 따라서 자릿수가 늘어난 경우에는 모든 자리에서 일치하는지 여부를 확인하도록 한다.&lt;b&gt;&lt;/b&gt;&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position: relative !important; overflow: auto;&quot;&gt;
&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin: 0; padding: 0; border: none; background-color: #272727; border-radius: 4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;padding: 6px; border-right: 2px solid #4f4f4f;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; word-break: normal; text-align: right; color: #aaa; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;1&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;2&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;3&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;4&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;5&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;6&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;7&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;8&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;9&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;10&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;11&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;12&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;13&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;padding: 6px 0; text-align: left;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;N&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;input()&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;i&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;while&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;True&lt;/span&gt;:&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;i&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;num&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;str&lt;/span&gt;(i)&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;while&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;len&lt;/span&gt;(num)&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;and&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;len&lt;/span&gt;(N):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;num[&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;]&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;N[&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;]:&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;N&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;N[&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;:]&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;num&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;num[&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;:]&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;len&lt;/span&gt;(N)&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;:&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;print&lt;/span&gt;(i)&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;vertical-align: bottom; padding: 0 2px 4px 0;&quot;&gt;&lt;a style=&quot;text-decoration: none; color: white;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: #4f4f4f; color: white; border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;문제링크:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/1515&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://www.acmicpc.net/problem/1515&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1689557235684&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;1515번: 수 이어 쓰기&quot; data-og-description=&quot;세준이는 1부터 N까지 모든 수를 차례대로 공백없이 한 줄에 다 썼다. 그리고 나서, 세준이가 저녁을 먹으러 나간 사이에 다솜이는 세준이가 쓴 수에서&amp;nbsp;마음에 드는 몇 개의 숫자를 지웠다. 세준&quot; data-og-host=&quot;www.acmicpc.net&quot; data-og-source-url=&quot;https://www.acmicpc.net/problem/1515&quot; data-og-url=&quot;https://www.acmicpc.net/problem/1515&quot; data-og-image=&quot;&quot;&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/1515&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-source-url=&quot;https://www.acmicpc.net/problem/1515&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;1515번: 수 이어 쓰기&lt;/p&gt;
&lt;p class=&quot;og-desc&quot; data-ke-size=&quot;size16&quot;&gt;세준이는 1부터 N까지 모든 수를 차례대로 공백없이 한 줄에 다 썼다. 그리고 나서, 세준이가 저녁을 먹으러 나간 사이에 다솜이는 세준이가 쓴 수에서&amp;nbsp;마음에 드는 몇 개의 숫자를 지웠다. 세준&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;div id=&quot;__endic_crx__&quot;&gt;
&lt;div class=&quot;css-diqpy0&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;</description>
      <category>Algorithm/Python</category>
      <category>1515</category>
      <category>BOJ</category>
      <category>Python</category>
      <category>문자열</category>
      <category>백준</category>
      <category>브루트 포스</category>
      <category>수 이어 쓰기</category>
      <category>알고리즘</category>
      <category>파이썬</category>
      <author>Pycoder</author>
      <guid isPermaLink="true">https://codedrive.tistory.com/585</guid>
      <comments>https://codedrive.tistory.com/585#entry585comment</comments>
      <pubDate>Mon, 24 Jul 2023 12:00:40 +0900</pubDate>
    </item>
    <item>
      <title>[Programmers] Lv 2. 무인도 여행</title>
      <link>https://codedrive.tistory.com/584</link>
      <description>&lt;h4 data-ke-size=&quot;size20&quot;&gt;문제:&lt;/h4&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignCenter&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-origin-width=&quot;982&quot; data-origin-height=&quot;221&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/bkWLfZ/btsnE9888Og/LDT1GOpBXkIQq7OOEu26a0/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/bkWLfZ/btsnE9888Og/LDT1GOpBXkIQq7OOEu26a0/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/bkWLfZ/btsnE9888Og/LDT1GOpBXkIQq7OOEu26a0/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbkWLfZ%2FbtsnE9888Og%2FLDT1GOpBXkIQq7OOEu26a0%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;982&quot; height=&quot;221&quot; data-origin-width=&quot;982&quot; data-origin-height=&quot;221&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;풀이방법:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;숫자를 만난 순간부터 계속해서 숫자를 연속해서 탐지할 수 있도록 알고리즘을 구성해야 하고 따라서 DFS를 사용해서 해당 문제를 풀었다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;maps를 탐색하다가 X가 아니고, 이전에 탐색한 곳이 아니라면 DFS를 수행하며, 연속된 영역을 탐색하는 동안 visited를 계속해서 갱신하도록 한다. 이와 같은 과정을 방문할 곳이 남아 있지 않을 때까지 수행하고, 각 영역의 넓이는 마지막에 정렬을 하도록 한다.(단, 정렬할 영역이 없다면 -1을 반환)&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position: relative !important; overflow: auto;&quot;&gt;
&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin: 0; padding: 0; border: none; background-color: #272727; border-radius: 4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;padding: 6px; border-right: 2px solid #4f4f4f;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; word-break: normal; text-align: right; color: #aaa; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;1&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;2&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;3&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;4&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;5&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;6&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;7&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;8&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;9&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;10&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;11&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;12&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;13&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;14&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;15&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;16&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;17&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;18&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;19&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;20&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;21&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;22&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;23&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;24&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;25&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;26&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;27&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;28&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;29&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;30&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;31&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;32&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;33&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;padding: 6px 0; text-align: left;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;from&lt;/span&gt;&amp;nbsp;collections&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;import&lt;/span&gt;&amp;nbsp;deque&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;dx&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;[&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;]&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;dy&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;[&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;]&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;def&lt;/span&gt;&amp;nbsp;dfs(x,&amp;nbsp;y,&amp;nbsp;maps,&amp;nbsp;visited):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;area&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;(maps[x][y])&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;queue&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;deque([(x,y)])&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;while&lt;/span&gt;&amp;nbsp;queue:&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x,&amp;nbsp;y&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;queue.popleft()&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #c10aff;&quot;&gt;4&lt;/span&gt;):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nx&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;x&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&amp;nbsp;dx[i]&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ny&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;y&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&amp;nbsp;dy[i]&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;nx&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;len&lt;/span&gt;(maps)&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;and&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;ny&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;len&lt;/span&gt;(maps[&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;]):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;maps[nx][ny]&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ffd500;&quot;&gt;'X'&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;and&lt;/span&gt;&amp;nbsp;visited[nx][ny]&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;:&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;area&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;(maps[nx][ny])&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;visited[nx][ny]&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;queue.append((nx,&amp;nbsp;ny))&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;return&lt;/span&gt;&amp;nbsp;area,&amp;nbsp;visited&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;def&lt;/span&gt;&amp;nbsp;solution(maps):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;visited&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;[[&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;_&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #4be6fa;&quot;&gt;len&lt;/span&gt;(maps[&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;]))]&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;_&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #4be6fa;&quot;&gt;len&lt;/span&gt;(maps))]&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answers&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;[]&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #4be6fa;&quot;&gt;len&lt;/span&gt;(maps)):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #4be6fa;&quot;&gt;len&lt;/span&gt;(maps[&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;])):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;maps[i][j]&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ffd500;&quot;&gt;'X'&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;and&lt;/span&gt;&amp;nbsp;visited[i][j]&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;:&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;visited[i][j]&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer,&amp;nbsp;visited&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;dfs(i,&amp;nbsp;j,&amp;nbsp;maps,&amp;nbsp;visited)&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answers.append(answer)&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;len&lt;/span&gt;(answers):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;return&lt;/span&gt;&amp;nbsp;sorted(answers)&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;else&lt;/span&gt;:&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;return&lt;/span&gt;&amp;nbsp;[&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;]&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: right; margin-top: -13px; margin-right: 5px; font-size: 9px; font-style: italic;&quot;&gt;&lt;a style=&quot;color: #4f4f4ftext-decoration:none;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;vertical-align: bottom; padding: 0 2px 4px 0;&quot;&gt;&lt;a style=&quot;text-decoration: none; color: white;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: #4f4f4f; color: white; border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;문제링크:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a href=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/154540&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://school.programmers.co.kr/learn/courses/30/lessons/154540&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1689556989787&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/154540&quot; data-og-url=&quot;https://programmers.co.kr/&quot; data-og-image=&quot;https://scrap.kakaocdn.net/dn/bgdbqe/hyTk9bdUza/UWuRfAObjasL1jkt8KoJt0/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/A6hC3/hyTleQ75Sm/xYNhAisZT4vMPo5jpGiToK/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/154540&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-source-url=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/154540&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url('https://scrap.kakaocdn.net/dn/bgdbqe/hyTk9bdUza/UWuRfAObjasL1jkt8KoJt0/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/A6hC3/hyTleQ75Sm/xYNhAisZT4vMPo5jpGiToK/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;div id=&quot;__endic_crx__&quot;&gt;
&lt;div class=&quot;css-diqpy0&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;</description>
      <category>Algorithm/Python</category>
      <category>dfs</category>
      <category>Lv 2.</category>
      <category>Python</category>
      <category>무인도 여행</category>
      <category>알고리즘</category>
      <category>파이썬</category>
      <category>프로그래머스</category>
      <author>Pycoder</author>
      <guid isPermaLink="true">https://codedrive.tistory.com/584</guid>
      <comments>https://codedrive.tistory.com/584#entry584comment</comments>
      <pubDate>Fri, 21 Jul 2023 12:00:18 +0900</pubDate>
    </item>
    <item>
      <title>[BOJ] 19941. 햄버거 분배</title>
      <link>https://codedrive.tistory.com/583</link>
      <description>&lt;h4 data-ke-size=&quot;size20&quot;&gt;문제:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;기다란 벤치 모양의 식탁에 사람들과 햄버거가 아래와 같이 단위 간격으로 놓여 있다. 사람들은 자신의 위치에서 거리가&lt;span&gt; &lt;/span&gt;&lt;span aria-hidden=&quot;true&quot;&gt;K&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;이하인 햄버거를 먹을 수 있다.&lt;/p&gt;
&lt;table style=&quot;background-color: #ffffff; color: #333333; text-align: start; border-collapse: collapse; width: 100%;&quot; border=&quot;1&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align: center;&quot;&gt;햄버거&lt;/td&gt;
&lt;td style=&quot;text-align: center;&quot;&gt;사람&lt;/td&gt;
&lt;td style=&quot;text-align: center;&quot;&gt;햄버거&lt;/td&gt;
&lt;td style=&quot;text-align: center;&quot;&gt;사람&lt;/td&gt;
&lt;td style=&quot;text-align: center;&quot;&gt;햄버거&lt;/td&gt;
&lt;td style=&quot;text-align: center;&quot;&gt;사람&lt;/td&gt;
&lt;td style=&quot;text-align: center;&quot;&gt;햄버거&lt;/td&gt;
&lt;td style=&quot;text-align: center;&quot;&gt;햄버거&lt;/td&gt;
&lt;td style=&quot;text-align: center;&quot;&gt;사람&lt;/td&gt;
&lt;td style=&quot;text-align: center;&quot;&gt;사람&lt;/td&gt;
&lt;td style=&quot;text-align: center;&quot;&gt;햄버거&lt;/td&gt;
&lt;td style=&quot;text-align: center;&quot;&gt;사람&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align: center;&quot;&gt;&lt;b&gt;1&lt;/b&gt;&lt;/td&gt;
&lt;td style=&quot;text-align: center;&quot;&gt;&lt;b&gt;2&lt;/b&gt;&lt;/td&gt;
&lt;td style=&quot;text-align: center;&quot;&gt;&lt;b&gt;3&lt;/b&gt;&lt;/td&gt;
&lt;td style=&quot;text-align: center;&quot;&gt;&lt;b&gt;4&lt;/b&gt;&lt;/td&gt;
&lt;td style=&quot;text-align: center;&quot;&gt;&lt;b&gt;5&lt;/b&gt;&lt;/td&gt;
&lt;td style=&quot;text-align: center;&quot;&gt;&lt;b&gt;6&lt;/b&gt;&lt;/td&gt;
&lt;td style=&quot;text-align: center;&quot;&gt;&lt;b&gt;7&lt;/b&gt;&lt;/td&gt;
&lt;td style=&quot;text-align: center;&quot;&gt;&lt;b&gt;8&lt;/b&gt;&lt;/td&gt;
&lt;td style=&quot;text-align: center;&quot;&gt;&lt;b&gt;9&lt;/b&gt;&lt;/td&gt;
&lt;td style=&quot;text-align: center;&quot;&gt;&lt;b&gt;10&lt;/b&gt;&lt;/td&gt;
&lt;td style=&quot;text-align: center;&quot;&gt;&lt;b&gt;11&lt;/b&gt;&lt;/td&gt;
&lt;td style=&quot;text-align: center;&quot;&gt;&lt;b&gt;12&lt;/b&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot; data-ke-size=&quot;size16&quot;&gt;위의 상태에서&lt;span&gt; &lt;/span&gt;&lt;span aria-hidden=&quot;true&quot;&gt;K = 1&lt;/span&gt;인 경우를 생각해보자. 이 경우 모든 사람은 자신과&amp;nbsp;인접한 햄버거만 먹을 수 있다. 10번의 위치에 있는 사람은 11번 위치에 있는 햄버거를 먹을 수 있다. 이 경우 다음과 같이 최대 5명의 사람이 햄버거를 먹을 수 있다.&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc; background-color: #ffffff; color: #333333; text-align: start;&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li style=&quot;color: #555555;&quot;&gt;2번 위치에 있는 사람: 1번 위치에 있는 햄버거&lt;/li&gt;
&lt;li style=&quot;color: #555555;&quot;&gt;4번 위치에 있는 사람: 5번 위치에 있는 햄버거&lt;/li&gt;
&lt;li style=&quot;color: #555555;&quot;&gt;6번 위치에 있는 사람: 7번 위치에 있는 햄버거&lt;/li&gt;
&lt;li style=&quot;color: #555555;&quot;&gt;9번 위치에 있는 사람: 8번 위치에 있는 햄버거&lt;/li&gt;
&lt;li style=&quot;color: #555555;&quot;&gt;10번 위치에 있는 사람: 11번 위치에 있는 햄버거&lt;/li&gt;
&lt;li style=&quot;color: #555555;&quot;&gt;12번 위치에 있는 사람: 먹을 수 있는 햄버거가 없음&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot; data-ke-size=&quot;size16&quot;&gt; &lt;span aria-hidden=&quot;true&quot;&gt;K = 2&lt;/span&gt;인 경우에는 6명 모두가 햄버거를 먹을 수 있다.&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc; background-color: #ffffff; color: #333333; text-align: start;&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li style=&quot;color: #555555;&quot;&gt;2번 위치에 있는 사람: 1번 위치에 있는 햄버거&lt;/li&gt;
&lt;li style=&quot;color: #555555;&quot;&gt;4번 위치에 있는 사람: 3번 위치에 있는 햄버거&lt;/li&gt;
&lt;li style=&quot;color: #555555;&quot;&gt;6번 위치에 있는 사람: 5번 위치에 있는 햄버거&lt;/li&gt;
&lt;li style=&quot;color: #555555;&quot;&gt;9번 위치에 있는 사람: 7번 위치에 있는 햄버거&lt;/li&gt;
&lt;li style=&quot;color: #555555;&quot;&gt;10번 위치에 있는 사람: 8번 위치에 있는 햄버거&lt;/li&gt;
&lt;li style=&quot;color: #555555;&quot;&gt;12번 위치에 있는 사람: 11번 위치에 있는 햄버거&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot; data-ke-size=&quot;size16&quot;&gt;식탁의 길이&lt;span&gt; &lt;/span&gt;&lt;span aria-hidden=&quot;true&quot;&gt;N&lt;/span&gt;, 햄버거를 선택할 수 있는 거리&lt;span&gt; &lt;/span&gt;&lt;span aria-hidden=&quot;true&quot;&gt;K&lt;/span&gt;, 사람과 햄버거의 위치가 주어졌을 때, 햄버거를 먹을 수 있는 사람의 최대 수를 구하는 프로그램을 작성하시오.&lt;/p&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;입력:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;span style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot;&gt;첫 줄에 두 정수&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&lt;span aria-hidden=&quot;true&quot;&gt;N&lt;/span&gt;&lt;span style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot;&gt;과&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&lt;span aria-hidden=&quot;true&quot;&gt;K&lt;/span&gt;&lt;span style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot;&gt;가 있다. 그리고 다음 줄에 사람과 햄버거의 위치가 문자&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;P&lt;span style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot;&gt;(사람)와&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;H&lt;span style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot;&gt;(햄버거)로 이루어지는 길이&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&lt;span aria-hidden=&quot;true&quot;&gt;N&lt;/span&gt;&lt;span style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot;&gt;인 문자열로 주어진다.&lt;/span&gt;&lt;/p&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;출력:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;span style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot;&gt;첫 줄에 햄버거를 먹을 수 있는 최대 사람 수를 나타낸다&lt;/span&gt;&lt;/p&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;풀이방법:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;사람을 기준으로 -K인 인덱스부터 햄버거를 우선 배정하는 그리디 알고리즘을 사용한다. 인덱스를 사용하기 때문에 IndexError가 발생하지 않도록 주의한다.&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position: relative !important; overflow: auto;&quot;&gt;
&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin: 0; padding: 0; border: none; background-color: #272727; border-radius: 4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;padding: 6px; border-right: 2px solid #4f4f4f;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; word-break: normal; text-align: right; color: #aaa; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;1&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;2&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;3&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;4&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;5&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;6&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;7&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;8&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;9&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;10&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;11&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;12&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;13&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;14&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;15&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;16&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;17&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;padding: 6px 0; text-align: left;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;N,&amp;nbsp;K&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;map(&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;,&amp;nbsp;input().split())&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;burger&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;list(input())&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;answer&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #4be6fa;&quot;&gt;len&lt;/span&gt;(burger)):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;burger[i]&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ffd500;&quot;&gt;'P'&lt;/span&gt;:&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;idx&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;i&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;K&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;idx&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;:&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;idx&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;while&lt;/span&gt;&amp;nbsp;idx&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;and&lt;/span&gt;&amp;nbsp;idx&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;i&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;K&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;and&lt;/span&gt;&amp;nbsp;idx&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;N:&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;burger[idx]&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ffd500;&quot;&gt;'H'&lt;/span&gt;:&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;burger[idx]&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ffd500;&quot;&gt;''&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;idx&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;print&lt;/span&gt;(answer)&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: right; margin-top: -13px; margin-right: 5px; font-size: 9px; font-style: italic;&quot;&gt;&lt;a style=&quot;color: #4f4f4ftext-decoration:none;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;vertical-align: bottom; padding: 0 2px 4px 0;&quot;&gt;&lt;a style=&quot;text-decoration: none; color: white;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: #4f4f4f; color: white; border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;문제링크:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/19941&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://www.acmicpc.net/problem/19941&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1689556621854&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;19941번: 햄버거 분배&quot; data-og-description=&quot;기다란 벤치 모양의 식탁에 사람들과 햄버거가 아래와 같이 단위 간격으로 놓여 있다. 사람들은 자신의 위치에서 거리가 $K$ 이하인 햄버거를 먹을 수 있다. 햄버거 사람 햄버거 사람 햄버거 사&quot; data-og-host=&quot;www.acmicpc.net&quot; data-og-source-url=&quot;https://www.acmicpc.net/problem/19941&quot; data-og-url=&quot;https://www.acmicpc.net/problem/19941&quot; data-og-image=&quot;https://scrap.kakaocdn.net/dn/eehzIF/hyTk2iRSUx/3qMK8818MiTkDzV4qZgp6k/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/19941&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-source-url=&quot;https://www.acmicpc.net/problem/19941&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url('https://scrap.kakaocdn.net/dn/eehzIF/hyTk2iRSUx/3qMK8818MiTkDzV4qZgp6k/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;19941번: 햄버거 분배&lt;/p&gt;
&lt;p class=&quot;og-desc&quot; data-ke-size=&quot;size16&quot;&gt;기다란 벤치 모양의 식탁에 사람들과 햄버거가 아래와 같이 단위 간격으로 놓여 있다. 사람들은 자신의 위치에서 거리가 $K$ 이하인 햄버거를 먹을 수 있다. 햄버거 사람 햄버거 사람 햄버거 사&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;div id=&quot;__endic_crx__&quot;&gt;
&lt;div class=&quot;css-diqpy0&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;</description>
      <category>Algorithm/Python</category>
      <category>19941</category>
      <category>BOJ</category>
      <category>Python</category>
      <category>그리디</category>
      <category>백준</category>
      <category>알고리즘</category>
      <category>파이썬</category>
      <category>햄버거 분배</category>
      <author>Pycoder</author>
      <guid isPermaLink="true">https://codedrive.tistory.com/583</guid>
      <comments>https://codedrive.tistory.com/583#entry583comment</comments>
      <pubDate>Thu, 20 Jul 2023 12:00:22 +0900</pubDate>
    </item>
    <item>
      <title>[BOJ] 20920. 영단어 암기는 괴로워</title>
      <link>https://codedrive.tistory.com/582</link>
      <description>&lt;h4 data-ke-size=&quot;size20&quot;&gt;문제:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;화은이는 이번 영어 시험에서 틀린 문제를 바탕으로 영어 단어 암기를 하려고 한다. 그 과정에서 효율적으로 영어 단어를 외우기 위해 영어 단어장을 만들려&amp;nbsp;하고 있다. 화은이가 만들고자 하는 단어장의 단어 순서는 다음과 같은 우선순위를 차례로 적용하여 만들어진다.&lt;/p&gt;
&lt;ol style=&quot;list-style-type: decimal; background-color: #ffffff; color: #333333; text-align: start;&quot; data-ke-list-type=&quot;decimal&quot;&gt;
&lt;li style=&quot;color: #555555;&quot;&gt;자주 나오는 단어일수록 앞에 배치한다.&lt;/li&gt;
&lt;li style=&quot;color: #555555;&quot;&gt;해당 단어의 길이가 길수록 앞에 배치한다.&lt;/li&gt;
&lt;li style=&quot;color: #555555;&quot;&gt;알파벳 사전 순으로 앞에 있는&amp;nbsp;단어일수록 앞에 배치한다&lt;/li&gt;
&lt;/ol&gt;
&lt;p style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot; data-ke-size=&quot;size16&quot;&gt; &lt;span aria-hidden=&quot;true&quot;&gt;M&lt;/span&gt;보다 짧은 길이의 단어의 경우 읽는 것만으로도 외울 수 있기 때문에 길이가&lt;span&gt; &lt;/span&gt;&lt;span aria-hidden=&quot;true&quot;&gt;M&lt;/span&gt;이상인 단어들만 외운다고 한다. 화은이가 괴로운 영단어 암기를 효율적으로 할 수 있도록 단어장을 만들어 주자.&lt;/p&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;입력:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;첫째 줄에는 영어 지문에 나오는 단어의 개수&lt;span&gt; &lt;/span&gt;&lt;span aria-hidden=&quot;true&quot;&gt;N&lt;/span&gt;과 외울 단어의 길이 기준이 되는&lt;span&gt; &lt;/span&gt;&lt;span aria-hidden=&quot;true&quot;&gt;M&lt;/span&gt;이 공백으로 구분되어 주어진다. (1&amp;le; N &amp;le;100,000,&lt;span&gt;&amp;nbsp;&lt;/span&gt;1&amp;le; M &amp;le;10)&lt;/p&gt;
&lt;p style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot; data-ke-size=&quot;size16&quot;&gt;둘째 줄부터&lt;span&gt; &lt;/span&gt;&lt;span aria-hidden=&quot;true&quot;&gt;N+1&lt;/span&gt;번째 줄까지 외울 단어를 입력받는다. 이때의 입력은 알파벳 소문자로만 주어지며 단어의 길이는&lt;span&gt; &lt;/span&gt;&lt;span aria-hidden=&quot;true&quot;&gt;10&lt;/span&gt;을 넘지 않는다.&lt;/p&gt;
&lt;p style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot; data-ke-size=&quot;size16&quot;&gt;단어장에&amp;nbsp;단어가 반드시 1개 이상 존재하는&amp;nbsp;입력만 주어진다.&lt;/p&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;출력:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;span style=&quot;background-color: #ffffff; color: #555555; text-align: start;&quot;&gt;화은이의 단어장에 들어 있는 단어를 단어장의 앞에 위치한 단어부터 한 줄에 한 단어씩 순서대로 출력한다.&lt;/span&gt;&lt;/p&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;풀이방법:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;defaultdict을 사용해서 나오는 횟수를 카운팅하며 (key, value) 값을 조건에 맞게 정렬하고 출력하도록 한다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;시간 제한이 걸려 있는 문제이므로 일반 input 대신 sys.stdin.readline을 사용해야 하며, rstrip()으로 개행문자를 제거해 주도록 한다.&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position: relative !important; overflow: auto;&quot;&gt;
&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin: 0; padding: 0; border: none; background-color: #272727; border-radius: 4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;padding: 6px; border-right: 2px solid #4f4f4f;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; word-break: normal; text-align: right; color: #aaa; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;1&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;2&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;3&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;4&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;5&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;6&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;7&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;8&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;9&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;10&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;11&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;12&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;13&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;14&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;15&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;16&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;padding: 6px 0; text-align: left;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;import&lt;/span&gt;&amp;nbsp;sys&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;from&lt;/span&gt;&amp;nbsp;collections&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;import&lt;/span&gt;&amp;nbsp;defaultdict&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;input&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;sys.stdin.readline&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;N,&amp;nbsp;M&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;map(&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;,&amp;nbsp;input().rstrip().split())&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;count_dict&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;defaultdict(&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;)&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;_&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;range&lt;/span&gt;(N):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;word&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;input().rstrip()&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;len&lt;/span&gt;(word)&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;M:&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;count_dict[word]&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;counts&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;sorted(count_dict.items(),&amp;nbsp;key&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;lambda&amp;nbsp;x:&amp;nbsp;(&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;x[&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;],&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;len&lt;/span&gt;(x[&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;]),&amp;nbsp;x[&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;]))&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;c&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;counts:&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;print&lt;/span&gt;(c[&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;])&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: right; margin-top: -13px; margin-right: 5px; font-size: 9px; font-style: italic;&quot;&gt;&lt;a style=&quot;color: #4f4f4ftext-decoration:none;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;vertical-align: bottom; padding: 0 2px 4px 0;&quot;&gt;&lt;a style=&quot;text-decoration: none; color: white;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: #4f4f4f; color: white; border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;문제링크:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/20920&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://www.acmicpc.net/problem/20920&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1689222858332&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;20920번: 영단어 암기는 괴로워&quot; data-og-description=&quot;첫째 줄에는 영어 지문에 나오는 단어의 개수 $N$과 외울 단어의 길이 기준이 되는 $M$이 공백으로 구분되어 주어진다. ($1&amp;nbsp;\leq N&amp;nbsp;\leq 100\,000$, $1&amp;nbsp;\leq M&amp;nbsp;\leq 10$) 둘째 줄부터 $N+1$번째 줄까지 외울 단&quot; data-og-host=&quot;www.acmicpc.net&quot; data-og-source-url=&quot;https://www.acmicpc.net/problem/20920&quot; data-og-url=&quot;https://www.acmicpc.net/problem/20920&quot; data-og-image=&quot;&quot;&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/20920&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-source-url=&quot;https://www.acmicpc.net/problem/20920&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;20920번: 영단어 암기는 괴로워&lt;/p&gt;
&lt;p class=&quot;og-desc&quot; data-ke-size=&quot;size16&quot;&gt;첫째 줄에는 영어 지문에 나오는 단어의 개수 $N$과 외울 단어의 길이 기준이 되는 $M$이 공백으로 구분되어 주어진다. ($1&amp;nbsp;\leq N&amp;nbsp;\leq 100\,000$, $1&amp;nbsp;\leq M&amp;nbsp;\leq 10$) 둘째 줄부터 $N+1$번째 줄까지 외울 단&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;</description>
      <category>Algorithm/Python</category>
      <category>20920</category>
      <category>BOJ</category>
      <category>Python</category>
      <category>문자열</category>
      <category>백준</category>
      <category>알고리즘</category>
      <category>영단어 암기는 괴로워</category>
      <category>정렬</category>
      <category>파이썬</category>
      <category>해시를 사용한 집합과 맵</category>
      <author>Pycoder</author>
      <guid isPermaLink="true">https://codedrive.tistory.com/582</guid>
      <comments>https://codedrive.tistory.com/582#entry582comment</comments>
      <pubDate>Wed, 19 Jul 2023 12:00:58 +0900</pubDate>
    </item>
    <item>
      <title>[Programmers] Lv 2. 연속된 부분 수열의 합</title>
      <link>https://codedrive.tistory.com/580</link>
      <description>&lt;h4 data-ke-size=&quot;size20&quot;&gt;문제:&lt;/h4&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignCenter&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-origin-width=&quot;960&quot; data-origin-height=&quot;250&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/cQtO6T/btsm9wCHOjp/9LMQDH3ZCs1fdpnYruQNVK/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/cQtO6T/btsm9wCHOjp/9LMQDH3ZCs1fdpnYruQNVK/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/cQtO6T/btsm9wCHOjp/9LMQDH3ZCs1fdpnYruQNVK/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FcQtO6T%2Fbtsm9wCHOjp%2F9LMQDH3ZCs1fdpnYruQNVK%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;960&quot; height=&quot;250&quot; data-origin-width=&quot;960&quot; data-origin-height=&quot;250&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;풀이방법:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;투 포인터를 사용해서 문제를 해결하도록 한다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;s,e 두 개의 포인터를 사용하며 K보다 작다면 e를 계속해서 증가시키고, k와 같아진 경우 answer를 조건에 맞게 최신화한다. 이 과정이 끝나면 s를 증가시켜 다음 탐색을 진행한다.&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position: relative !important; overflow: auto;&quot;&gt;
&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin: 0; padding: 0; border: none; background-color: #272727; border-radius: 4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;padding: 6px; border-right: 2px solid #4f4f4f;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; word-break: normal; text-align: right; color: #aaa; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;1&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;2&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;3&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;4&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;5&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;6&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;7&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;8&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;9&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;10&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;11&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;12&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;13&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;14&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;15&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;16&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;17&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;18&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;padding: 6px 0; text-align: left;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;def&lt;/span&gt;&amp;nbsp;solution(sequence,&amp;nbsp;k):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;[]&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;L&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;len&lt;/span&gt;(sequence)&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;s,&amp;nbsp;e&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;parse_sum&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;sequence[&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;]&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;s&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;range&lt;/span&gt;(L):&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;while&lt;/span&gt;&amp;nbsp;e&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;L&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;and&lt;/span&gt;&amp;nbsp;parse_sum&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;k:&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;parse_sum&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;sequence[e]&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;parse_sum&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;k:&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;not&lt;/span&gt;&amp;nbsp;answer:&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;[s,&amp;nbsp;e]&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;else&lt;/span&gt;:&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ans_s,&amp;nbsp;ans_e&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;answer&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;e&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;s&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;ans_e&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;ans_s:&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;[s,&amp;nbsp;e]&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;parse_sum&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;sequence[s]&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;return&lt;/span&gt;&amp;nbsp;answer&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;vertical-align: bottom; padding: 0 2px 4px 0;&quot;&gt;&lt;a style=&quot;text-decoration: none; color: white;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: #4f4f4f; color: white; border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;문제링크:&lt;/h4&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a href=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/178870&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://school.programmers.co.kr/learn/courses/30/lessons/178870&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1689039321411&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/178870&quot; data-og-url=&quot;https://programmers.co.kr/&quot; data-og-image=&quot;https://scrap.kakaocdn.net/dn/pN51r/hyTiBdmXAh/J2TRvC3x0h2zg4jdnBfOW0/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/eeDDPO/hyTiyubdJX/lz9Vi1J9kNDfwCjGaeiN7K/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/178870&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-source-url=&quot;https://school.programmers.co.kr/learn/courses/30/lessons/178870&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url('https://scrap.kakaocdn.net/dn/pN51r/hyTiBdmXAh/J2TRvC3x0h2zg4jdnBfOW0/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/eeDDPO/hyTiyubdJX/lz9Vi1J9kNDfwCjGaeiN7K/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;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;</description>
      <category>Algorithm/Python</category>
      <category>Lv2</category>
      <category>programmers</category>
      <category>Python</category>
      <category>알고리즘</category>
      <category>연속된 부분 수열의 합</category>
      <category>투 포인터</category>
      <category>파이썬</category>
      <category>프로그래머스</category>
      <author>Pycoder</author>
      <guid isPermaLink="true">https://codedrive.tistory.com/580</guid>
      <comments>https://codedrive.tistory.com/580#entry580comment</comments>
      <pubDate>Tue, 18 Jul 2023 12:00:36 +0900</pubDate>
    </item>
  </channel>
</rss>