{"id":3735,"date":"2018-10-24T19:57:28","date_gmt":"2018-10-24T16:57:28","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=3735"},"modified":"2018-10-24T19:58:51","modified_gmt":"2018-10-24T16:58:51","slug":"e-olymp-440-%d0%bf%d0%be%d0%b4%d0%b4%d0%b5%d0%bb%d0%ba%d0%b0-%d1%87%d0%b5%d0%ba%d0%b0","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=3735","title":{"rendered":"e-olymp 440. \u041f\u043e\u0434\u0434\u0435\u043b\u043a\u0430 \u0447\u0435\u043a\u0430"},"content":{"rendered":"<h1>\u0417\u0430\u0434\u0430\u0447\u0430<\/h1>\n<p>\u041e\u0434\u0438\u043d \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043c\u043e\u0448\u0435\u043d\u043d\u0438\u0447\u0435\u0441\u0442\u0432\u0430, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0445 \u041e. \u0411\u0435\u043d\u0434\u0435\u0440\u043e\u043c, \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u043b\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c. \u041e\u043d \u0432\u044b\u0440\u0435\u0437\u0430\u043b \u043f\u043e\u043b\u043e\u0441\u043a\u0443 \u0431\u0443\u043c\u0430\u0433\u0438, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0443\u044e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0446\u0438\u0444\u0440 \u0438\u0437 \u0441\u0443\u043c\u043c\u044b \u0447\u0435\u043a\u0430 (\u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0440\u0435\u0437\u0430\u0442\u044c \u0438 \u043a\u0440\u0430\u0439\u043d\u0438\u0435 \u0446\u0438\u0444\u0440\u044b), \u0440\u0430\u0437\u0440\u0435\u0437\u0430\u043b \u0435\u0435 \u043d\u0430 \u0434\u0432\u0435 \u0447\u0430\u0441\u0442\u0438, \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0432\u043b\u044f\u043b \u044d\u0442\u0438 \u0434\u0432\u0435 \u0447\u0430\u0441\u0442\u0438 \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0438 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u0435\u0438\u0432\u0430\u043b \u043e\u0431\u0440\u0430\u0442\u043d\u043e. \u041d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0443\u044e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438.<\/p>\n<h2><em>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/em><\/h2>\n<p>\u0412\u043e \u0432\u0445\u043e\u0434\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u043e\u0434\u043d\u043e \u0446\u0435\u043b\u043e\u0435 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u0438\u0437 $100$ \u0446\u0438\u0444\u0440.<\/p>\n<h2><em>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/em><\/h2>\n<p>\u0412 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u0444\u0430\u0439\u043b \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u2013 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438, \u0438\u043b\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u0435\u0441\u043b\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e.<\/p>\n<h2>\u0422\u0435\u0441\u0442\u044b<\/h2>\n<table>\n<tbody>\n<tr>\n<td><strong>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/strong><\/td>\n<td><strong>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/strong><\/td>\n<\/tr>\n<tr>\n<td>$123321$<\/td>\n<td>$332121$<\/td>\n<\/tr>\n<tr>\n<td>$7888778888878888788878878777887$<\/td>\n<td>$8888878888788878887778878777887$<\/td>\n<\/tr>\n<tr>\n<td>$1091$<\/td>\n<td>$9100$<\/td>\n<\/tr>\n<tr>\n<td>$26364$<\/td>\n<td>$64263$<\/td>\n<\/tr>\n<tr>\n<td>$98765$<\/td>\n<td>$98765$<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u041a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/h2>\n<pre class=\"lang:java decode:true \" title=\"440.Solution\">import java.io.BufferedReader;\r\nimport java.io.IOException;\r\nimport java.io.InputStreamReader;\r\n\r\npublic class Main {\r\n    public static void main(String[] args) throws IOException{\r\n        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));\r\n        String s = bufferedReader.readLine();\r\n        String maxS = s;\r\n        int start = s.length() - 1;\r\n        boolean found = false;\r\n        for (int i = 0; i &lt; s.length() &amp;&amp; !found; i++) {\r\n            for (int j = i; j &lt; s.length() &amp;&amp; !found; j++) {\r\n                if (s.charAt(j) &gt; s.charAt(i)) {\r\n                    start = i;\r\n                    found = true;\r\n                }\r\n            }\r\n        }\r\n        for (int j = start + 1; j &lt; s.length(); j++) {\r\n            StringBuilder curMax = new StringBuilder(s);\r\n            if (s.charAt(j) &gt;= s.charAt(start)) {\r\n                for (int k = j; k &lt; s.length(); k++) {\r\n                    curMax.insert(start + k - j, s.charAt(k));\r\n                    curMax.delete(k + 1, k + 2);\r\n                    String curMaxString = curMax.toString();\r\n                    if (curMaxString.compareTo(maxS) &gt; 0) {\r\n                        maxS = curMaxString;\r\n                    }\r\n                }\r\n            }\r\n        }\r\n        System.out.println(maxS);\r\n    }\r\n}<\/pre>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438<\/h2>\n<p>\u041f\u0443\u0441\u0442\u044c \u0437\u0430\u0434\u0430\u043d\u044b \u0434\u0432\u0430 \u0447\u0438\u0441\u043b\u0430: $a = \\overline{a_1a_2 \\ldots a_k},\\ b = \\overline{b_1b_2 \\ldots b_k}$. \u0422\u043e\u0433\u0434\u0430 $a &gt; b \\Leftrightarrow \\exists i: \\ \\forall j &lt; i \\ a_j = b_j \\ \\wedge \\ a_i &gt; b_i$. \u041e\u0442\u0441\u044e\u0434\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u0432 \u0437\u0430\u043f\u0438\u0441\u0438 \u0447\u0438\u0441\u043b\u0430 $a$ \u0433\u0440\u0443\u043f\u043f \u0446\u0438\u0444\u0440 $\\overline{a_ia_{i+1} \\ldots a_l}$ \u0438 $\\overline{a_ja_{j+1} \\ldots a_m} \\ l&lt;j$ \u043c\u0435\u0441\u0442\u0430\u043c\u0438: $i = \\min_{1 &lt; s &lt; k} s: \\ \\exists t&gt;s: \\ a_t \\gt a_s$. \u0415\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0435 $i$ \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0442\u043e \u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u0431\u043e\u0440 \u043f\u043e \u0432\u0441\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430\u043c, \u0442\u0430\u043a\u0438\u043c \u0447\u0442\u043e \u043f\u0435\u0440\u0432\u0430\u044f \u0433\u0440\u0443\u043f\u043f\u0430 \u0447\u0438\u0441\u0435\u043b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 $i$ \u0438 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e. \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u0430\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0443\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c.<\/p>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\n<p><a href=\"https:\/\/www.e-olymp.com\/ru\/problems\/440\" target=\"_blank\" rel=\"noopener\">\u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430 e-olymp<\/a><br \/>\n<a href=\"https:\/\/www.e-olymp.com\/ru\/submissions\/4601430\" target=\"_blank\" rel=\"noopener\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 e-olymp<\/a><br \/>\n<a href=\"https:\/\/ideone.com\/FWqhrC\" target=\"_blank\" rel=\"noopener\">\u041a\u043e\u0434 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430 Ideone. String<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u041e\u0434\u0438\u043d \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043c\u043e\u0448\u0435\u043d\u043d\u0438\u0447\u0435\u0441\u0442\u0432\u0430, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0445 \u041e. \u0411\u0435\u043d\u0434\u0435\u0440\u043e\u043c, \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u043b\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c. \u041e\u043d \u0432\u044b\u0440\u0435\u0437\u0430\u043b \u043f\u043e\u043b\u043e\u0441\u043a\u0443 \u0431\u0443\u043c\u0430\u0433\u0438, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0443\u044e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0446\u0438\u0444\u0440 \u0438\u0437 \u0441\u0443\u043c\u043c\u044b \u0447\u0435\u043a\u0430 (\u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0440\u0435\u0437\u0430\u0442\u044c \u0438 \u043a\u0440\u0430\u0439\u043d\u0438\u0435 \u0446\u0438\u0444\u0440\u044b), \u0440\u0430\u0437\u0440\u0435\u0437\u0430\u043b \u0435\u0435 \u043d\u0430 \u0434\u0432\u0435 \u0447\u0430\u0441\u0442\u0438, \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0432\u043b\u044f\u043b \u044d\u0442\u0438 \u0434\u0432\u0435 \u0447\u0430\u0441\u0442\u0438 \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0438 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u0435\u0438\u0432\u0430\u043b \u043e\u0431\u0440\u0430\u0442\u043d\u043e. \u041d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0443\u044e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438. \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=3735\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":119,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105],"tags":[405,406,407],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/3735"}],"collection":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/users\/119"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3735"}],"version-history":[{"count":2,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/3735\/revisions"}],"predecessor-version":[{"id":3737,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/3735\/revisions\/3737"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3735"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3735"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3735"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}