<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mediawiki.zeropage.org/index.php?action=history&amp;feed=atom&amp;title=AdventuresInMoving%3APartIV%2F%EB%AC%B8%EB%B3%B4%EC%B0%BD</id>
	<title>AdventuresInMoving:PartIV/문보창 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mediawiki.zeropage.org/index.php?action=history&amp;feed=atom&amp;title=AdventuresInMoving%3APartIV%2F%EB%AC%B8%EB%B3%B4%EC%B0%BD"/>
	<link rel="alternate" type="text/html" href="https://mediawiki.zeropage.org/index.php?title=AdventuresInMoving:PartIV/%EB%AC%B8%EB%B3%B4%EC%B0%BD&amp;action=history"/>
	<updated>2026-05-14T15:43:44Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.8</generator>
	<entry>
		<id>https://mediawiki.zeropage.org/index.php?title=AdventuresInMoving:PartIV/%EB%AC%B8%EB%B3%B4%EC%B0%BD&amp;diff=27523&amp;oldid=prev</id>
		<title>imported&gt;Unknown at 05:22, 7 February 2021</title>
		<link rel="alternate" type="text/html" href="https://mediawiki.zeropage.org/index.php?title=AdventuresInMoving:PartIV/%EB%AC%B8%EB%B3%B4%EC%B0%BD&amp;diff=27523&amp;oldid=prev"/>
		<updated>2021-02-07T05:22:26Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== 소감 ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| 2005-12-29 Accepted 1.703 440&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 코드 ==&lt;br /&gt;
 // 10201 - Adventures in Moving: Part IV&lt;br /&gt;
 #include &amp;amp;lt;iostream&amp;amp;gt;&lt;br /&gt;
 using namespace std;&lt;br /&gt;
 &lt;br /&gt;
 //#include &amp;amp;lt;fstream&amp;amp;gt;&lt;br /&gt;
 //fstream cin(&amp;quot;in.txt&amp;quot;);&lt;br /&gt;
 &lt;br /&gt;
 #define MAX_OIL 200&lt;br /&gt;
 #define MAX_SIZE 101&lt;br /&gt;
 #define MAX_NUM 1000000000&lt;br /&gt;
 &lt;br /&gt;
 typedef struct&lt;br /&gt;
 {&lt;br /&gt;
 	int length;&lt;br /&gt;
 	int price;&lt;br /&gt;
 }Station;&lt;br /&gt;
 &lt;br /&gt;
 static int totalLength;				/* 워털루에서 대도시까지의 거리 */&lt;br /&gt;
 static int numStation;				/* 주유소 수 */&lt;br /&gt;
 static Station station[MAX_SIZE];	/* 주유소 정보 */&lt;br /&gt;
 static int d[2][MAX_OIL+1];			/* 다이나믹 테이블 */&lt;br /&gt;
 &lt;br /&gt;
 inline &lt;br /&gt;
 int getDistance(int i) &lt;br /&gt;
 { &lt;br /&gt;
 	return station[i].length - station[i-1].length; &lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void input()&lt;br /&gt;
 {&lt;br /&gt;
 	cin &amp;amp;gt;&amp;amp;gt; totalLength;&lt;br /&gt;
 	cin.get();&lt;br /&gt;
 	numStation = 0;&lt;br /&gt;
 	while (cin.peek() != EOF &amp;amp;amp;&amp;amp;amp; cin.peek() != &amp;#039;\n&amp;#039;)&lt;br /&gt;
 	{&lt;br /&gt;
 		numStation++;&lt;br /&gt;
 		cin &amp;amp;gt;&amp;amp;gt; station[numStation].length &amp;amp;gt;&amp;amp;gt; station[numStation].price;&lt;br /&gt;
 		cin.get();&lt;br /&gt;
 	}&lt;br /&gt;
 	cin.get();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void initTable()&lt;br /&gt;
 {&lt;br /&gt;
 	station[0].length = 0;&lt;br /&gt;
 	for (int j = 0; j &amp;amp;lt;= MAX_OIL; j++)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (100 - station[1].length &amp;amp;lt; 0 || j &amp;amp;lt; 100 - station[1].length)&lt;br /&gt;
 			d[1][j] = MAX_NUM;&lt;br /&gt;
 		else&lt;br /&gt;
 			d[1][j] = (j - 100 + station[1].length) * station[1].price;&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void process()&lt;br /&gt;
 {&lt;br /&gt;
 	int min, cost;&lt;br /&gt;
 	int i, j, k;&lt;br /&gt;
 	initTable();&lt;br /&gt;
 &lt;br /&gt;
 	if (numStation == 1)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (totalLength - station[numStation].length &amp;amp;gt; 100 || station[1].length &amp;amp;gt; 100)&lt;br /&gt;
 			cout &amp;amp;lt;&amp;amp;lt; &amp;quot;Impossible\n&amp;quot;;&lt;br /&gt;
 		else&lt;br /&gt;
 			cout &amp;amp;lt;&amp;amp;lt; d[1][totalLength - station[numStation].length + 100] &amp;amp;lt;&amp;amp;lt; endl;&lt;br /&gt;
 		return;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	for (i = 2; i &amp;amp;lt;= numStation; i++)&lt;br /&gt;
 	{&lt;br /&gt;
 		for (j = 0; j &amp;amp;lt;= MAX_OIL; j++)&lt;br /&gt;
 		{&lt;br /&gt;
 			min = MAX_NUM;&lt;br /&gt;
 			for (k = 0; k &amp;amp;lt;= MAX_OIL; k++)&lt;br /&gt;
 			{&lt;br /&gt;
 				if (k - getDistance(i) &amp;amp;lt; 0 || d[(i-1)%2][k] &amp;amp;gt;= MAX_NUM || j &amp;amp;lt; k - getDistance(i))&lt;br /&gt;
 					continue;&lt;br /&gt;
 				cost = d[(i-1)%2][k] + (j - k + getDistance(i)) * station[i].price;&lt;br /&gt;
 				if (cost &amp;amp;lt; min)&lt;br /&gt;
 					min = cost;&lt;br /&gt;
 			}&lt;br /&gt;
 			d[i%2][j] = min;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	min = MAX_NUM;&lt;br /&gt;
 	for (j = 100; j &amp;amp;lt;= MAX_OIL; j++)&lt;br /&gt;
 	{&lt;br /&gt;
 		if (d[numStation%2][j] &amp;amp;lt; MAX_NUM &amp;amp;amp;&amp;amp;amp; d[numStation%2][j] &amp;amp;lt; min &amp;amp;amp;&amp;amp;amp; j - (totalLength - station[numStation].length) &amp;amp;gt;= 100)&lt;br /&gt;
 			min = d[numStation%2][j];&lt;br /&gt;
 	}&lt;br /&gt;
 	if (min &amp;amp;gt;= MAX_NUM)&lt;br /&gt;
 	{&lt;br /&gt;
 		cout &amp;amp;lt;&amp;amp;lt; &amp;quot;Impossible\n&amp;quot;;&lt;br /&gt;
 		return;&lt;br /&gt;
 	}&lt;br /&gt;
 	cout &amp;amp;lt;&amp;amp;lt; min &amp;amp;lt;&amp;amp;lt; endl;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main()&lt;br /&gt;
 {&lt;br /&gt;
 	int numCase;&lt;br /&gt;
 	cin &amp;amp;gt;&amp;amp;gt; numCase;&lt;br /&gt;
 	cin.get(), cin.get();&lt;br /&gt;
 	for (int i = 0; i &amp;amp;lt; numCase; i++)&lt;br /&gt;
 	{&lt;br /&gt;
 		input();&lt;br /&gt;
 		process();&lt;br /&gt;
 		if (i != numCase - 1)&lt;br /&gt;
 			cout &amp;amp;lt;&amp;amp;lt; endl;&lt;br /&gt;
 	}&lt;br /&gt;
 	return 0;&lt;br /&gt;
 }&lt;br /&gt;
----&lt;br /&gt;
[[AdventuresInMoving:PartIV]] [[문보창]]&lt;br /&gt;
&lt;/div&gt;</summary>
		<author><name>imported&gt;Unknown</name></author>
	</entry>
</feed>