{"id":3269,"date":"2012-04-12T08:21:04","date_gmt":"2012-04-12T08:21:04","guid":{"rendered":"http:\/\/wp.binus.ac.id\/?p=3269"},"modified":"2012-04-12T08:21:04","modified_gmt":"2012-04-12T08:21:04","slug":"contoh-soal-5713-qin-shi-huangs-national-road-system","status":"publish","type":"post","link":"https:\/\/simprug.binus.sch.id\/id\/2012\/04\/12\/contoh-soal-5713-qin-shi-huangs-national-road-system\/","title":{"rendered":"[contoh soal] 5713 &#8211; Qin Shi Huang&#8217;s National Road System"},"content":{"rendered":"<p>\t\t\t\tDuring the Warring States Period of ancient China(476 BC to 221 BC), there were seven kingdoms in China &#8212; they were Qi, Chu, Yan, Han, Zhao, Wei and Qin. Ying Zheng was the king of the kingdom Qin. Through 9 years of wars, he finally conquered all six other kingdoms and became the first emperor of a unified China in 221 BC. That was Qin dynasty &#8212; the first imperial dynasty of China(not to be confused with the Qing Dynasty, the last dynasty of China). So Ying Zheng named himself &#8220;Qin Shi Huang&#8221; because &#8220;Shi Huang&#8221; means &#8220;the first emperor &#8221; in Chinese.<\/p>\n<p>&nbsp;<\/p>\n<div align=\"CENTER\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/livearchive.onlinejudge.org\/external\/57\/p5713.png\" alt=\"epsfbox{p5713.eps}\" width=\"428\" height=\"609\" align=\"BOTTOM\" border=\"0\" \/><\/div>\n<p>Qin Shi Huang undertook gigantic projects, including the first version of the Great Wall of China, the now famous city-sized mausoleum guarded by a life-sized Terracotta Army, and a massive national road system. There is a story about the road system:<\/p>\n<p>There were\u00a0<em>n<\/em>\u00a0cities in China and Qin Shi Huang wanted them all be connected by\u00a0<em>n<\/em>\u00a0&#8211; 1roads, in order that he could go to every city from the capital city Xianyang. Although Qin Shi Huang was a tyrant, he wanted the total length of all roads to be minimum,so that the road system may not cost too many people&#8217;s life. A daoshi (some kind of monk) named Xu Fu told Qin Shi Huang that he could build a road by magic and that magic road would cost no money and no labor. But Xu Fu could only build ONE magic road for Qin Shi Huang. So Qin Shi Huang had to decide where to build the magic road. Qin Shi Huang wanted the total length of all none magic roads to be as small as possible, but Xu Fu wanted the magic road to benefit as many people as possible &#8212; So Qin Shi Huang decided that the value of\u00a0<em>A<\/em>\/<em>B<\/em>\u00a0(the ratio of\u00a0<em>A<\/em>\u00a0to\u00a0<em>B<\/em>) must be the maximum, which\u00a0<em>A<\/em>\u00a0is the total population of the two cites connected by the magic road, and\u00a0<em>B<\/em>\u00a0is the total length of none magic roads.<\/p>\n<p>Would you help Qin Shi Huang?<\/p>\n<p>A city can be considered as a point, and a road can be considered as a line segment connecting two points.<\/p>\n<p>&nbsp;<\/p>\n<h2><span style=\"color: #ff0000;font-size: medium\"><a name=\"SECTION0001001000000000000000\"><\/a>Input\u00a0<\/span><\/h2>\n<p>The first line contains an integer\u00a0<em>t<\/em>\u00a0meaning that there are\u00a0<em>t<\/em>\u00a0test cases\u00a0(<em>t<\/em><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/livearchive.onlinejudge.org\/external\/57\/5713img2.png\" alt=\"$ le$\" width=\"18\" height=\"31\" align=\"MIDDLE\" border=\"0\" \/>10).<\/p>\n<p>For each test case:<\/p>\n<p>The first line is an integer\u00a0<em>n<\/em>\u00a0meaning that there are\u00a0<em>n<\/em>\u00a0cities\u00a0(2 &lt;\u00a0<em>n<\/em><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/livearchive.onlinejudge.org\/external\/57\/5713img2.png\" alt=\"$ le$\" width=\"18\" height=\"31\" align=\"MIDDLE\" border=\"0\" \/>1000).<\/p>\n<p>Then\u00a0<em>n<\/em>\u00a0lines follow. Each line contains three integers\u00a0<em>X<\/em>,\u00a0<em>Y<\/em>\u00a0and\u00a0<em>P<\/em>\u00a0(0<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/livearchive.onlinejudge.org\/external\/57\/5713img2.png\" alt=\"$ le$\" width=\"18\" height=\"31\" align=\"MIDDLE\" border=\"0\" \/><em>X<\/em>,\u00a0<em>Y<\/em><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/livearchive.onlinejudge.org\/external\/57\/5713img2.png\" alt=\"$ le$\" width=\"18\" height=\"31\" align=\"MIDDLE\" border=\"0\" \/>1000, 0 &lt;\u00a0<em>P<\/em>&lt; 100000).\u00a0(<em>X<\/em>,\u00a0<em>Y<\/em>)\u00a0is the coordinate of a city and\u00a0<em>P<\/em>\u00a0is the population of that city.<\/p>\n<p>It is guaranteed that each city has a distinct location.<\/p>\n<p>&nbsp;<\/p>\n<h2><span style=\"color: #ff0000;font-size: medium\"><a name=\"SECTION0001002000000000000000\"><\/a>Output\u00a0<\/span><\/h2>\n<p>For each test case, print a line indicating the above mentioned maximum ratio\u00a0<em>A<\/em>\/<em>B<\/em>. The result should be rounded to 2 digits after decimal point.<\/p>\n<p>&nbsp;<\/p>\n<h2><span style=\"color: #ff0000;font-size: medium\"><a name=\"SECTION0001003000000000000000\"><\/a>Sample Input\u00a0<\/span><\/h2>\n<p>&nbsp;<\/p>\n<pre>2\n4\n1 1 20\n1 2 30\n200 2 80\n200 1 100\n3\n1 1 20\n1 2 30\n2 2 40<\/pre>\n<p>&nbsp;<\/p>\n<h2><span style=\"color: #ff0000;font-size: medium\"><a name=\"SECTION0001004000000000000000\"><\/a>Sample Output\u00a0<\/span><\/h2>\n<p>&nbsp;<\/p>\n<pre>65.00\n70.00<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>During the Warring States Period of ancient China(476 BC to 221 BC), there were seven kingdoms in China &#8212; they were Qi, Chu, Yan, Han, Zhao, Wei and Qin. Ying Zheng was the king of the kingdom Qin. Through 9 years of wars, he finally conquered all six other kingdoms and became the first emperor [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3269","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/simprug.binus.sch.id\/id\/wp-json\/wp\/v2\/posts\/3269","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/simprug.binus.sch.id\/id\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/simprug.binus.sch.id\/id\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/simprug.binus.sch.id\/id\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/simprug.binus.sch.id\/id\/wp-json\/wp\/v2\/comments?post=3269"}],"version-history":[{"count":0,"href":"https:\/\/simprug.binus.sch.id\/id\/wp-json\/wp\/v2\/posts\/3269\/revisions"}],"wp:attachment":[{"href":"https:\/\/simprug.binus.sch.id\/id\/wp-json\/wp\/v2\/media?parent=3269"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/simprug.binus.sch.id\/id\/wp-json\/wp\/v2\/categories?post=3269"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/simprug.binus.sch.id\/id\/wp-json\/wp\/v2\/tags?post=3269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}