<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>맞았습니다 Archives - 어제와 내일의 나 그 사이의 이야기</title>
	<atom:link href="https://lycos7560.com/tag/%EB%A7%9E%EC%95%98%EC%8A%B5%EB%8B%88%EB%8B%A4/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>생각의 흐름을 타고 다니며 만드는 블로그</description>
	<lastBuildDate>Thu, 23 Feb 2023 00:15:54 +0000</lastBuildDate>
	<language>ko-KR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>

<image>
	<url>https://lycos7560.com/wp-content/uploads/2022/11/cropped-cropped-cropped-log-1-150x150-1-80x80.png</url>
	<title>맞았습니다 Archives - 어제와 내일의 나 그 사이의 이야기</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>백준 1449번 (수리공 항승, C++, set) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon-1449%eb%b2%88-%ec%88%98%eb%a6%ac%ea%b3%b5-%ed%95%ad%ec%8a%b9-c-set/597/</link>
					<comments>https://lycos7560.com/cpp/baekjoon-1449%eb%b2%88-%ec%88%98%eb%a6%ac%ea%b3%b5-%ed%95%ad%ec%8a%b9-c-set/597/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Fri, 28 Oct 2022 16:40:01 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[1449번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[iterator]]></category>
		<category><![CDATA[SET]]></category>
		<category><![CDATA[맞았습니다]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 1449]]></category>
		<category><![CDATA[백준 1449번]]></category>
		<category><![CDATA[수리공 항승]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[예제]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.synology.me/?p=597</guid>

					<description><![CDATA[<p>백준 1449번(BAEKJOON) '수리공 항승' 문제에 대한 글입니다. 자료구조 set을 사용하여 해결하였습니다. (This is an article on the issue of 'Supervisor Hangseung' by BAEKJOON. I solved it using the data structure set.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon-1449%eb%b2%88-%ec%88%98%eb%a6%ac%ea%b3%b5-%ed%95%ad%ec%8a%b9-c-set/597/">백준 1449번 (수리공 항승, C++, set) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<!-- HorizontalAD -->
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5698326622209671" data-ad-slot="6908948342" data-ad-format="auto" data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading">수리공 항승</h1>



<p class="has-medium-font-size wp-block-paragraph"><a href="https://www.acmicpc.net/problem/1449" target="_blank" rel="noreferrer noopener">www.acmicpc.net/problem/1449</a></p>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<figure id="problem-info" class="wp-block-table is-style-regular"><table class="has-ast-global-color-8-color has-ast-global-color-6-background-color has-text-color has-background"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">2 초</td><td class="has-text-align-left" data-align="left">128 MB</td><td class="has-text-align-left" data-align="left">15241</td><td class="has-text-align-left" data-align="left">6921</td><td class="has-text-align-left" data-align="left">5785</td><td class="has-text-align-left" data-align="left">45.351%</td></tr></tbody></table></figure>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="has-large-font-size wp-block-heading">문제</h2>



<p class="has-medium-font-size wp-block-paragraph">항승이는 품질이 심각하게 나쁜 수도 파이프 회사의 수리공이다. <br>항승이는 세준 지하철 공사에서 물이 샌다는 소식을 듣고 수리를 하러 갔다.<br> 파이프에서 물이 새는 곳은 신기하게도 가장 왼쪽에서 정수만큼 떨어진 거리만 물이 샌다. <br>항승이는 길이가 L인 테이프를 무한 개 가지고 있다. <br>항승이는 테이프를 이용해서 물을 막으려고 한다. <br><br>항승이는 항상 물을 막을 때, <br>적어도 그 위치의 좌우 0.5만큼 간격을 줘야 물이 다시는 안 샌다고 생각한다. </p>



<p class="has-medium-font-size wp-block-paragraph">물이 새는 곳의 위치와, 항승이가 가지고 있는 테이프의 길이 L이 주어졌을 때, <br>항승이가 필요한 테이프의 최소 개수를 구하는 프로그램을 작성하시오. <br>테이프를 자를 수 없고, 테이프를 겹쳐서 붙이는 것도 가능하다.</p>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="has-large-font-size wp-block-heading">입력</h2>



<p class="has-medium-font-size wp-block-paragraph">첫째 줄에 물이 새는 곳의 개수 N과 테이프의 길이 L이 주어진다. <br>둘째 줄에는 물이 새는 곳의 위치가 주어진다. <br>N과 L은 1,000보다 작거나 같은 자연수이고, <br>물이 새는 곳의 위치는 1,000보다 작거나 같은 자연수이다.</p>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="has-large-font-size wp-block-heading">출력</h2>



<p class="has-medium-font-size wp-block-paragraph">첫째 줄에 항승이가 필요한 테이프의 개수를 출력한다.</p>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="has-medium-font-size wp-block-heading">예제 입력 1</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">4 2
1 2 100 101
</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="has-medium-font-size wp-block-heading">예제 출력 1</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">2</pre>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="has-medium-font-size wp-block-heading">예제 입력 2</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">4 3
1 2 3 4
</pre>



<div style="height:33px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="has-medium-font-size wp-block-heading">예제 출력 2</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">2
</pre>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="has-medium-font-size wp-block-heading">예제 입력 3</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">3 1
3 2 1
</pre>



<div style="height:47px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="has-medium-font-size wp-block-heading">예제 출력 3</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">3
</pre>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="has-medium-font-size wp-block-heading">출처</h2>



<ul class="wp-block-list">
<li>문제를 번역한 사람:&nbsp;<a href="https://www.acmicpc.net/user/baekjoon" target="_blank" rel="noreferrer noopener">baekjoon</a></li>



<li>문제의 오타를 찾은 사람:&nbsp;<a href="https://www.acmicpc.net/user/rainshot" target="_blank" rel="noreferrer noopener">rainshot</a></li>



<li>잘못된 데이터를 찾은 사람:&nbsp;<a href="https://www.acmicpc.net/user/tncks0121" target="_blank" rel="noreferrer noopener">tncks0121</a></li>
</ul>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="has-medium-font-size wp-block-heading">알고리즘 분류</h2>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/33" target="_blank" rel="noreferrer noopener">그리디 알고리즘</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/97" target="_blank" rel="noreferrer noopener">정렬</a></li>
</ul>



<div style="height:97px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="has-medium-font-size wp-block-paragraph">파이프에서 물이 새는 곳은 가장 왼쪽에서 정수만큼 떨어진 거리<br>길이가 L인 테이프를 무한 가지고 있음<br>물을 막을 때 좌우 0.5 만큼 간격을 줘야 물이 안샘<br>물이 새는 곳의 위치와 테이프의 길이 L 이 주어졌을 때 필요한 테이프의 최소 개수<br>테이프는 자를 수 없고 겹쳐서 붙이는 것도 가능</p>



<p class="has-medium-font-size wp-block-paragraph">첫째 줄에 물이 새는 곳의 개수 N / 테이프의 길이 L<br>둘째 줄에는 물이 새는 곳의 위치 (N)</p>



<div style="height:58px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="1206" height="483" src="https://lycos7560.com/wp-content/uploads/image-82.png" alt="" class="wp-image-2312" srcset="https://lycos7560.com/wp-content/uploads/image-82.png 1206w, https://lycos7560.com/wp-content/uploads/image-82-300x120.png 300w, https://lycos7560.com/wp-content/uploads/image-82-768x308.png 768w" sizes="(max-width: 1206px) 100vw, 1206px" /></figure>



<div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="has-medium-font-size wp-block-paragraph">물이 세는 곳은 겹치지 않고 정렬되어 들어온다는 보장도 없으니<br>위치를 set에 저장하고 테이프를 추가하는 형식으로 구현해보려고 한다.</p>



<div style="height:42px" aria-hidden="true" class="wp-block-spacer"></div>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5698326622209671" data-ad-slot="4245812909"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:46px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="has-large-font-size wp-block-heading"><strong>데이터 입력 확인</strong></h2>



<div style="height:39px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;set>

using namespace std;

set&lt;int> myset;
set&lt;int> :: iterator iter;

int temp = 0;
int lenghtTape = 0;

void Intialization()
{
	int N = 0;
	cin >> N >> lenghtTape;
	while (N > 0)
	{
		cin >> temp;
		myset.insert(temp);
		N--;
	}
}


int main()
{
	Intialization();
    
	cout &lt;&lt; "\n";
    
	for (iter = myset.begin(); iter != myset.end(); iter++)
	{
		cout &lt;&lt; *iter &lt;&lt; " ";
	}

	return 0;
}</pre>



<div style="height:71px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="392" height="104" src="https://lycos7560.com/wp-content/uploads/image-83.png" alt="" class="wp-image-2314" srcset="https://lycos7560.com/wp-content/uploads/image-83.png 392w, https://lycos7560.com/wp-content/uploads/image-83-300x80.png 300w" sizes="(max-width: 392px) 100vw, 392px" /></figure>



<div style="height:74px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="has-large-font-size wp-block-heading"><strong>통과된 답안</strong></h2>



<div style="height:37px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;set>

using namespace std;

set&lt;int> myset;
set&lt;int> :: iterator iter;

int temp = 0;
int lenghtTape = 0;
int result = 0;

// 초기화 함수
void Intialization()
{
	int N = 0;
	cin >> N >> lenghtTape;
	while (N > 0)
	{
		cin >> temp;
		myset.insert(temp);
		N--;
	}
}

int main()
{
	// 조건을 초기화한다.
	Intialization();

	// 테이프가 커버 할 수 있는 끝 위치를 표시
	int pos = 0;

	// 셋에 넣어서 정렬된 물이 새는 위치를 순회한다.
	for (iter = myset.begin(); iter != myset.end(); iter++)
	{
		// 만약 새는 위치가 테이프가 커버 가능한 범위라면 넘어간다.
		if (*iter &lt;= pos)
		{
			continue;
		}

		// 테이프가 커버 가능한 위치가 아니므로 테이프를 추가하고 커버 범위를 넘겨준다.
		pos = *iter + (lenghtTape - 1);
		result++;
	}

	// 결과 출력
	cout &lt;&lt; result;
	return 0;
}</pre>



<div style="height:55px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="wp-block-paragraph"><strong>처음에는 코드를 어떻게 작성할지 막막했지만 한번 길을 잡으니 쉽게 해결됐다.</strong></p>



<div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="908" height="109" src="https://lycos7560.com/wp-content/uploads/image-86.png" alt="" class="wp-image-2315" srcset="https://lycos7560.com/wp-content/uploads/image-86.png 908w, https://lycos7560.com/wp-content/uploads/image-86-300x36.png 300w, https://lycos7560.com/wp-content/uploads/image-86-768x92.png 768w" sizes="(max-width: 908px) 100vw, 908px" /></figure>



<div style="height:74px" aria-hidden="true" class="wp-block-spacer"></div>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5698326622209671" data-ad-slot="4245812909"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon-1449%eb%b2%88-%ec%88%98%eb%a6%ac%ea%b3%b5-%ed%95%ad%ec%8a%b9-c-set/597/">백준 1449번 (수리공 항승, C++, set) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon-1449%eb%b2%88-%ec%88%98%eb%a6%ac%ea%b3%b5-%ed%95%ad%ec%8a%b9-c-set/597/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
