<?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>백준 2812 Archives - 어제와 내일의 나 그 사이의 이야기</title>
	<atom:link href="https://lycos7560.com/tag/%eb%b0%b1%ec%a4%80-2812/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>생각의 흐름을 타고 다니며 만드는 블로그</description>
	<lastBuildDate>Thu, 23 Feb 2023 00:15:33 +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>백준 2812 Archives - 어제와 내일의 나 그 사이의 이야기</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>백준 2812번 (크게 만들기, C++, Stack, Greedy) / 추가 반례 [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon-2812%eb%b2%88-%ed%81%ac%ea%b2%8c-%eb%a7%8c%eb%93%a4%ea%b8%b0-c-stack-greedy-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80/625/</link>
					<comments>https://lycos7560.com/cpp/baekjoon-2812%eb%b2%88-%ed%81%ac%ea%b2%8c-%eb%a7%8c%eb%93%a4%ea%b8%b0-c-stack-greedy-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80/625/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Fri, 28 Oct 2022 17:27:25 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[2812]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[Stack]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[반례]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 2812]]></category>
		<category><![CDATA[백준 2812번]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[예제]]></category>
		<category><![CDATA[추가 반례]]></category>
		<category><![CDATA[추가 예제]]></category>
		<category><![CDATA[추가반례]]></category>
		<category><![CDATA[추가예제]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<category><![CDATA[크게 만들기]]></category>
		<guid isPermaLink="false">https://lycos7560.synology.me/?p=625</guid>

					<description><![CDATA[<p>크게 만들기 www.acmicpc.net/problem/2812 시간 제한 메모리 제한 제출 정답 맞힌 사람 정답 비율 1 초 128 MB 21627 5528 3984 25.650% 문제 N자리 숫자가 주어졌을 때, 여기서 숫자 K개를 지워서 얻을 수 있는 가장 큰 수를 구하는 프로그램을 작성하시오. 입력 첫째 줄에 N과 K가 주어진다. (1 ≤ K &#60; N ≤ 500,000)둘째 줄에 N자리 숫자가 [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon-2812%eb%b2%88-%ed%81%ac%ea%b2%8c-%eb%a7%8c%eb%93%a4%ea%b8%b0-c-stack-greedy-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80/625/">백준 2812번 (크게 만들기, C++, Stack, Greedy) / 추가 반례 [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"><strong>크게 만들기</strong></h1>



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



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



<figure id="problem-info" class="wp-block-table is-style-stripes"><table class="has-ast-global-color-8-color has-ast-global-color-6-background-color has-text-color has-background has-fixed-layout"><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">1 초</td><td class="has-text-align-left" data-align="left">128 MB</td><td class="has-text-align-left" data-align="left">21627</td><td class="has-text-align-left" data-align="left">5528</td><td class="has-text-align-left" data-align="left">3984</td><td class="has-text-align-left" data-align="left">25.650%</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">N자리 숫자가 주어졌을 때, 여기서 숫자 K개를 지워서 <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과 K가 주어진다. (1 ≤ K &lt; N ≤ 500,000)<br>둘째 줄에 N자리 숫자가 주어진다. 이 수는 0으로 시작하지 않는다. </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">입력으로 주어진 숫자에서 K개를 지웠을 때 얻을 수 있는 가장 큰 수를 출력한다.</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
1924
</pre>



<div style="height:31px" 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="">94
</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="">7 3
1231234
</pre>



<div style="height:31px" 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="">3234
</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="">10 4
4177252841
</pre>



<div style="height:30px" 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="">775841
</pre>



<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-normal-font-size wp-block-paragraph"><a href="https://www.acmicpc.net/category/45" target="_blank" rel="noreferrer noopener">Contest</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/17" target="_blank" rel="noreferrer noopener">Croatian Open Competition in Informatics</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/19">CO</a><a href="https://www.acmicpc.net/category/19" target="_blank" rel="noreferrer noopener">C</a><a href="https://www.acmicpc.net/category/19">I 2011/2012</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/detail/71" target="_blank" rel="noreferrer noopener">Contest #4</a>&nbsp;3번</p>



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



<li>데이터를 추가한 사람:&nbsp;<a href="https://www.acmicpc.net/user/doju">doju</a>,&nbsp;<a href="https://www.acmicpc.net/user/engcraft">engcraft</a></li>
</ul>



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



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



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/175" target="_blank" rel="noreferrer noopener">자료 구조</a></li>



<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/71" target="_blank" rel="noreferrer noopener">스택</a></li>
</ul>



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



<h2 class="wp-block-heading"><strong>추가 예제</strong></h2>



<div class="wp-block-file"><a id="wp-block-file--media-b879d97d-6400-4ada-9521-f204a91acdda" href="https://lycos7560.com/wp-content/uploads/keks.7z">keks / 추가 예제</a><a href="https://lycos7560.com/wp-content/uploads/keks.7z" class="wp-block-file__button wp-element-button" download aria-describedby="wp-block-file--media-b879d97d-6400-4ada-9521-f204a91acdda">다운로드</a></div>



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



<p class="has-medium-font-size wp-block-paragraph"><a href="https://hsin.hr/coci/archive/2011_2012/" target="_blank" rel="noreferrer noopener">https://hsin.hr/coci/archive/2011_2012/</a></p>



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



<h2 class="has-medium-font-size wp-block-heading">예제 입력 A</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="">11 3
67429495152
</pre>



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



<h2 class="has-medium-font-size wp-block-heading">예제 출력 A</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="">79495152</pre>



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



<h2 class="has-medium-font-size wp-block-heading">예제 입력 B</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="">30 7
928857066163493066555730841879
</pre>



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



<h2 class="has-medium-font-size wp-block-heading">예제 출력 B</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="">98876693066555730841879</pre>



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



<h2 class="has-medium-font-size wp-block-heading">예제 입력 C</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="">9 2
999991111
</pre>



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



<h2 class="has-medium-font-size wp-block-heading">예제 출력 C</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="">9999911</pre>



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



<h2 class="has-medium-font-size wp-block-heading">예제 입력 D</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="">100 61
6617423282157290684025607883097699259905250470744165128706131448395502185407310941966307933122347117
</pre>



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



<h2 class="has-medium-font-size wp-block-heading">예제 출력 D</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="">999999955285407310941966307933122347117</pre>



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



<p class="has-medium-font-size wp-block-paragraph">K와 N의 범위 1 ≤ K &lt; N ≤ 500,000 -&gt; string 처리<br>N자리의 숫자가 주어졌을 때 N에서 K만큼 숫자를 제거<br>가장 큰 숫자를 찾는 것이 목적</p>



<div style="height:30px" 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; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-5698326622209671" data-ad-slot="5078714126"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



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



<h2 class="has-large-font-size wp-block-heading"><strong>실패한 로직과 코드</strong></h2>



<p class="has-medium-font-size wp-block-paragraph"><strong>숫자의 처음 기준으로 제거 가능한 개수의 숫자만큼 </strong><br><strong>인덱스 더한 범위 내에서 가장 큰 숫자를 기준으로 앞을 전부 제거</strong><br> <strong>-&gt; 만약 제거해야만 하는 숫자가 K의 범위보다 뒤에 있으면 잘못된 결과가 나온다. -&gt; 망한 로직&nbsp;</strong> </p>



<p class="has-medium-font-size wp-block-paragraph"><strong>위의 알고리즘으로 2시간은 넘게 고민함</strong><br> <strong>져서 다른 방법을 생각하지 못한다.</strong> </p>



<div style="height:48px" 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;string>

using namespace std;

int n, k;
char c;
string number = "";

void initalization()
{
	cin >> n >> k;

	int temp = n;
	while (temp > 0)
	{
		cin >> c;
		number.push_back(c);
		temp--;
	}
}

void test(int pivot, int k)
{
	if (k &lt;= 0) { return; }
	
	int maxnumberidx = 0;
	int numbercheck = -1;
	cout &lt;&lt; "시작 pivot : " &lt;&lt; pivot &lt;&lt; " 남은 지울 숫자 k : " &lt;&lt; k &lt;&lt; "\n";
	for (int i = pivot; i &lt;= k + pivot; i++)
	{
		if (numbercheck &lt; number[i] - '0')
		{
			numbercheck = number[i] - '0';
			maxnumberidx = i;
		}
	}
	
	cout &lt;&lt; "가장 큰 수 : " &lt;&lt; numbercheck &lt;&lt; " 인덱스 번호 : " &lt;&lt; maxnumberidx &lt;&lt; "\n";

	if (k == number.length() - 1)
	{
		if (k == 1)
		{
			numbercheck = 10;
			cout &lt;&lt; "numbercheck : " &lt;&lt; numbercheck &lt;&lt; " \n";
			cout &lt;&lt; "pivot : " &lt;&lt; pivot &lt;&lt; " number.length() : " &lt;&lt; number.length() &lt;&lt; "\n";
			for (int i = pivot; i &lt;= number.length() - 1; i++)
			{
				cout &lt;&lt; numbercheck &lt;&lt; " 비교 " &lt;&lt; number[i] - '0' &lt;&lt; "\n";
				if (numbercheck > number[i] - '0')
				{
					cout &lt;&lt; " 점검 number[i] - '0' :  " &lt;&lt; number[i] - '0' &lt;&lt; "\n";
					numbercheck = number[i] - '0';
					maxnumberidx = i;

				}

			}


			cout &lt;&lt; "-------------------------------------------------" &lt;&lt; "\n";
			cout &lt;&lt; "삭제 전 결과 : " &lt;&lt; number &lt;&lt; " maxnumberidx : " &lt;&lt; maxnumberidx &lt;&lt; "\n";
			number.erase(number.begin() + maxnumberidx, number.begin() + maxnumberidx + 1);
			cout &lt;&lt; "삭제 후 결과 : " &lt;&lt; number &lt;&lt; "\n";
			cout &lt;&lt; "-------------------------------------------------" &lt;&lt; "\n";
			return;
		}
	}

	cout &lt;&lt; "-------------------------------------------------" &lt;&lt; "\n";
	cout &lt;&lt; "삭제 전 결과 : " &lt;&lt; number &lt;&lt; "\n";
	number.erase(number.begin() + pivot, number.begin() + maxnumberidx);
	cout &lt;&lt; "삭제 후 결과 : " &lt;&lt; number &lt;&lt; "\n";
	cout &lt;&lt; "-------------------------------------------------" &lt;&lt; "\n";
	test(pivot + 1, k - (maxnumberidx - pivot) );
}

int main()
{
	initalization();
	
	test(0, k);
	//cout &lt;&lt; "n : " &lt;&lt; n &lt;&lt; " k : " &lt;&lt; k &lt;&lt; "  number : " &lt;&lt; number &lt;&lt; "\n";
}</pre>



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



<h2 class="has-large-font-size wp-block-heading"><strong>다른 로직</strong></h2>



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



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="972" height="1149" src="https://lycos7560.com/wp-content/uploads/image-96.png" alt="" class="wp-image-2334" srcset="https://lycos7560.com/wp-content/uploads/image-96.png 972w, https://lycos7560.com/wp-content/uploads/image-96-254x300.png 254w, https://lycos7560.com/wp-content/uploads/image-96-768x908.png 768w" sizes="(max-width: 972px) 100vw, 972px" /></figure>



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



<h2 class="wp-block-heading"><strong>통과된 코드</strong></h2>



<p class="wp-block-paragraph">문제를 해결하는 알고리즘이 떠오르지 않아서 시간을 많이 소요</p>



<p class="wp-block-paragraph">Stack 사용을 별로 해본 적이 없어서 문제 해결 방법에서 떠오르지 않았다.</p>



<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;string>
#include &lt;stack>

using namespace std;

stack&lt;char> myStack;
int n, k;
char c;
string number = "";
string result = "";

void Initalization()
{
	cin >> n >> k;

	int temp = n;
	while (temp > 0)
	{
		cin >> c;
		number.push_back(c);
		temp--;
	}
}


int main()
{
	// 입력을 초기화 해주는 함수
	Initalization();
	
	// 처음 시작을 위해 하나 넣어준다.
	myStack.push(number[0]);

	for (int i = 1; i &lt; number.length(); i++)
	{
		// 제거 가능한 수가 0 이면 스택에 넣고 넘어간다. 
		if (k == 0)
		{
			myStack.push(number[i]);
			continue;
		}
		
		// 만약 스택의 숫자보다 비교 숫자보다 크다면 
		// 스택의 숫자를 제거하고 다시 스텍의 수와 비교
		// 스텍이 비거나 비교 숫자보다 크거나 같으면 
		// 비교 숫자를 스택에 넣어준다.
		if (myStack.top() &lt; number[i])
		{

			while (myStack.top() &lt; number[i] &amp;&amp; !myStack.empty() &amp;&amp; k > 0)
			{
				myStack.pop();
				k--;
				if (myStack.empty())
				{
					break;
				}
			}

			myStack.push(number[i]);
		}
		else if (myStack.top() >= number[i])
		{ 
			// 만약 스택의 숫자보다 비교 숫자보다 크다면 
		    // 숫자를 스택에 넣어준다.
			myStack.push(number[i]);
			continue;
		}
	}

	// 모든 숫자를 전부다 비교해도 제거 가능한 숫자가 남으면
	// 그 수만큼 스택에서 제거한다.
	while (k > 0)
	{
		myStack.pop();
		k--;
	}

	while (!myStack.empty())
	{
		result.push_back(myStack.top());
		myStack.pop();
	}

	// 반대로 출력 되므로 뒤집어준다.
	string resultReverse(result.rbegin(), result.rend());
	cout &lt;&lt; resultReverse;
}</pre>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1204" height="138" src="https://lycos7560.com/wp-content/uploads/image-97.png" alt="" class="wp-image-2335" srcset="https://lycos7560.com/wp-content/uploads/image-97.png 1204w, https://lycos7560.com/wp-content/uploads/image-97-300x34.png 300w, https://lycos7560.com/wp-content/uploads/image-97-768x88.png 768w" sizes="(max-width: 1204px) 100vw, 1204px" /></figure>



<div style="height:100px" 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-2812%eb%b2%88-%ed%81%ac%ea%b2%8c-%eb%a7%8c%eb%93%a4%ea%b8%b0-c-stack-greedy-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80/625/">백준 2812번 (크게 만들기, C++, Stack, Greedy) / 추가 반례 [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon-2812%eb%b2%88-%ed%81%ac%ea%b2%8c-%eb%a7%8c%eb%93%a4%ea%b8%b0-c-stack-greedy-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80/625/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
