{"id":53,"date":"2011-08-17T08:21:06","date_gmt":"2011-08-17T08:21:06","guid":{"rendered":"http:\/\/www.uturtle.com\/blog\/archives\/53"},"modified":"2013-05-12T19:17:02","modified_gmt":"2013-05-12T19:17:02","slug":"uva-10137-the-trip","status":"publish","type":"post","link":"https:\/\/www.jinukbaek.com\/blog\/ko\/archives\/53","title":{"rendered":"UVA 10137 The Trip"},"content":{"rendered":"<p>\n&nbsp;# \ubb38\uc81c\uc810<br \/>\n&nbsp; &nbsp;&#8211; \uc785\ub825\uac12\uc758 \ubc18\uc62c\ub9bc \uc8fc\uc758 : Cent \uc774\ud558 \ub2e8\uc704\ub97c \ubb34\uc2dc\ud560 \uac83.<br \/>\n&nbsp; &nbsp;&#8211; \ub098\uba38\uc9c0 \ub3c8\uc758 \uade0\ub4f1\ubd84\ubc30.<\/p>\n<div class=\"txc-textbox\" style=\"border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-color: rgb(219, 232, 251); border-right-color: rgb(219, 232, 251); border-bottom-color: rgb(219, 232, 251); border-left-color: rgb(219, 232, 251); background-color: rgb(219, 232, 251); padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; \">\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">#include &lt;iostream&gt;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">#include &lt;algorithm&gt;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">#include &lt;iomanip&gt;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">#include &lt;cmath&gt;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">#include &lt;functional&gt;&nbsp;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">\n<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">using namespace std;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">\n<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">int main()<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">{<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t<\/span>int size;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t<\/span>int humens[1005];<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t<\/span>int humens_spent[1005];<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">\n<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t<\/span>cin &gt;&gt; size;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">\n<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t<\/span>while (size)<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t<\/span>{<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t<\/span>int sum = 0;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t<\/span>int avg;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">\n<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t<\/span>for (int i=0; i&lt;size; i++)<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t<\/span>{<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t\t<\/span>double temp;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t\t<\/span>cin &gt;&gt; temp;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t\t<\/span>humens[i] = (int)(temp * 100 + 0.5);<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t\t<\/span>sum += humens[i];<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t<\/span>}<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">\n<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t<\/span>sort(&amp;humens[0], &amp;humens[size], greater&lt;int&gt;() );<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">\n<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t<\/span>avg = sum\/size;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t<\/span>int remain = sum% size;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">\n<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t<\/span>sum = 0;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t<\/span>for (int i=0; i&lt;size; i++)<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t<\/span>{<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t\t<\/span>humens_spent[i] = avg;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t<\/span>}<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t<\/span><\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t<\/span>for (int i=0; i&lt;remain; i++)<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t<\/span>{<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t\t<\/span>humens_spent[i]++;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t<\/span>}<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t<\/span><\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t<\/span>for (int i=0; i&lt;size; i++)<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t<\/span>{<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t\t<\/span>sum += abs(humens_spent[i] &#8211; humens[i]);<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t<\/span>}<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">\n<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t<\/span>cout&lt;&lt; &#8220;$&#8221;&lt;&lt; fixed &lt;&lt; setprecision(2) &lt;&lt; (sum\/2)\/100.0 &lt;&lt; endl;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">\n<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t<\/span><\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t\t<\/span>cin &gt;&gt; size;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t<\/span>}<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">\n<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t<\/span>return 0;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">}<\/p>\n<\/p>\n<\/div>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;# \ubb38\uc81c\uc810 &nbsp; &nbsp;&#8211; \uc785\ub825\uac12\uc758 \ubc18\uc62c\ub9bc \uc8fc\uc758 : Cent \uc774\ud558 \ub2e8\uc704\ub97c \ubb34\uc2dc\ud560 \uac83. &nbsp; &nbsp;&#8211; \ub098\uba38\uc9c0 \ub3c8\uc758 \uade0\ub4f1\ubd84\ubc30.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[74],"tags":[],"class_list":["post-53","post","type-post","status-publish","format-standard","hentry","category-algorithm"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8gT1J-R","_links":{"self":[{"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/posts\/53","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/comments?post=53"}],"version-history":[{"count":1,"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/posts\/53\/revisions"}],"predecessor-version":[{"id":92,"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/posts\/53\/revisions\/92"}],"wp:attachment":[{"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/media?parent=53"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/categories?post=53"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/tags?post=53"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}