{"id":253,"date":"2018-06-02T15:24:06","date_gmt":"2018-06-02T07:24:06","guid":{"rendered":"https:\/\/dragonyue.fortiddns.com\/blog\/?p=253"},"modified":"2022-07-31T13:04:51","modified_gmt":"2022-07-31T05:04:51","slug":"java-uva10420","status":"publish","type":"post","link":"https:\/\/dragonyue.fortiddns.com\/blog\/java-uva10420\/","title":{"rendered":"Java &#8211; UVA10420"},"content":{"rendered":"<pre class=\"lang:java decode:1 \" >\r\nimport java.util.Arrays;\r\nimport java.util.Scanner;\r\n\r\n\/**\r\n * UVA10420\r\n *\/\r\npublic class UVA10420 {\r\n\r\n    public static void main(String[] args) {\r\n        Scanner sc = new Scanner(System.in);\r\n        int times = sc.nextInt();\r\n        sc.nextLine();\r\n        String[] country = new String[times];\r\n        for (int i = 0; i &lt; times; i++) {\r\n            country[i] = sc.next();\r\n            sc.nextLine();\r\n        }\r\n        Arrays.sort(country);\r\n        for (int i = 0; i &lt; country.length;) {\r\n            String index = country[i];\r\n            int count = 0;\r\n            for (int j = 0; j &lt; country.length; j++)\r\n                if (country[j].equals(index)) {\r\n                    count++;\r\n                    i = j + 1;\r\n                }\r\n            System.out.printf(&quot;%s %d\\r\\n&quot;, index, count);\r\n        }\r\n        sc.close();\r\n    }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>import java.util.Arrays; import java.util.Scanner; \/**  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-253","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/dragonyue.fortiddns.com\/blog\/wp-json\/wp\/v2\/posts\/253","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dragonyue.fortiddns.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dragonyue.fortiddns.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dragonyue.fortiddns.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dragonyue.fortiddns.com\/blog\/wp-json\/wp\/v2\/comments?post=253"}],"version-history":[{"count":1,"href":"https:\/\/dragonyue.fortiddns.com\/blog\/wp-json\/wp\/v2\/posts\/253\/revisions"}],"predecessor-version":[{"id":394,"href":"https:\/\/dragonyue.fortiddns.com\/blog\/wp-json\/wp\/v2\/posts\/253\/revisions\/394"}],"wp:attachment":[{"href":"https:\/\/dragonyue.fortiddns.com\/blog\/wp-json\/wp\/v2\/media?parent=253"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dragonyue.fortiddns.com\/blog\/wp-json\/wp\/v2\/categories?post=253"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dragonyue.fortiddns.com\/blog\/wp-json\/wp\/v2\/tags?post=253"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}