{"id":477,"date":"2019-02-19T23:40:56","date_gmt":"2019-02-19T14:40:56","guid":{"rendered":"http:\/\/www.mukgee.com\/?p=477"},"modified":"2020-12-27T01:24:17","modified_gmt":"2020-12-26T16:24:17","slug":"%ec%95%8c%ea%b3%a0%eb%a6%ac%ec%a6%98flatten","status":"publish","type":"post","link":"http:\/\/mukgee.com\/?p=477","title":{"rendered":"[\uc54c\uace0\ub9ac\uc998]Flatten"},"content":{"rendered":"<p>\ub192\uc740 \uacf3\uc758 \uc0c1\uc790\ub97c \ub0ae\uc740 \uacf3\uc5d0 \uc62e\uae30\ub294 \ubc29\uc2dd\uc73c\ub85c \ucd5c\uace0\uc810\uacfc \ucd5c\uc800\uc810\uc758 \uac04\uaca9\uc744 \uc904\uc774\ub294 \uc791\uc5c5\uc744 \ud3c9\ud0c4\ud654\ub77c\uace0 \ud55c\ub2e4.<\/p>\n<p>\ud3c9\ud0c4\ud654\ub97c \ubaa8\ub450 \uc218\ud589\ud558\uace0 \ub098\uba74, \uac00\uc7a5 \ub192\uc740 \uacf3\uacfc \uac00\uc7a5 \ub0ae\uc740 \uacf3\uc758 \ucc28\uc774\uac00 \ucd5c\ub300 1 \uc774\ub0b4\uac00 \ub41c\ub2e4.<\/p>\n<p>\ud3c9\ud0c4\ud654 \uc791\uc5c5\uc744 \uc704\ud574\uc11c \uc0c1\uc790\ub97c \uc62e\uae30\ub294 \uc791\uc5c5 \ud69f\uc218\uc5d0 \uc81c\ud55c\uc774 \uac78\ub824\uc788\uc744 \ub54c, \uc81c\ud55c\ub41c \ud69f\uc218\ub9cc\ud07c \uc62e\uae30\ub294 \uc791\uc5c5\uc744 \ud55c \ud6c4 \ucd5c\uace0\uc810\uacfc \ucd5c\uc800\uc810\uc758 \ucc28\uc774\ub97c \ubc18\ud658\ud558\ub294 \ud504\ub85c\uadf8\ub7a8\uc744 \uc791\uc131\ud558\uc2dc\uc624.<br \/>\n\ub2e8\uc21c\ud55c\u00a0Exhaustive Search\uac00 \uc544\ub2cc \ub2e4\ub978 \ubc29\ubc95\uc744 \ucc3e\uc544\ubcf4\ub824\uace0 \ud588\uc73c\ub098 \uc2e4\ud328.<\/p>\n<pre class=\"lang:default decode:true \">import java.util.Scanner;\npublic class Solution{\n    private static int testCase = 10;\n\n    public static void main(String[] args){\n\n        Scanner sc = new Scanner(System.in);\n        Solution sol = new Solution();\n\n        for(int inx = 0 ; inx &lt; testCase ; inx++){\n        \tString input1 = sc.nextLine();    \n            int dumpNum = Integer.parseInt(input1);\n            String inputs = sc.nextLine();\n            String[] inputNumber = inputs != null ? inputs.split(\" \") : null;\n            int[] numbers = sol.convertIntVal(inputNumber);\n            \n            for(int c = 0 ; c &lt; dumpNum ; c++){\n                int max = sol.getMaxIndex(numbers);\n                int min = sol.getMinIndex(numbers);\n              \tnumbers[max] = numbers[max] - 1; \n                numbers[min] = numbers[min] + 1;\n            }\n            int result = numbers[sol.getMaxIndex(numbers)] - numbers[ sol.getMinIndex(numbers)];\n            System.out.println(\"#\"+String.valueOf(inx+1) + \" \" + String.valueOf(result));\n        }\n        \n    }\n    public int[] convertIntVal(String[] numbers){\n        int[] result = new int[numbers.length];\n        for(int inx = 0 ; inx &lt; numbers.length ; inx++){\n            result[inx] = Integer.parseInt(numbers[inx]);\n        }\n        return result;\n    }\n    \n    public int getMaxIndex(int[] numbers){\n        int result = 0;\n        int MaxNum = 0;\n        for(int inx = 0 ; inx &lt; numbers.length ; inx++){\n            if(MaxNum &lt; numbers[inx]){\n                result = inx;\n                MaxNum = numbers[inx];\n            }\n        }\n        return result;\n    }\n    \n    public int getMinIndex(int[] numbers){\n        int result = 0;\n        int MinNum = 100;\n        for(int inx = 0 ; inx &lt; numbers.length ; inx++){\n            if(MinNum &gt; numbers[inx]){\n                result = inx;\n                MinNum = numbers[inx];\n            }\n        }\n        return result;\n    }\n    \n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\ub192\uc740 \uacf3\uc758 \uc0c1\uc790\ub97c \ub0ae\uc740 \uacf3\uc5d0 \uc62e\uae30\ub294 \ubc29\uc2dd\uc73c\ub85c \ucd5c\uace0\uc810\uacfc \ucd5c\uc800\uc810\uc758 \uac04\uaca9\uc744 \uc904\uc774\ub294 \uc791\uc5c5\uc744 \ud3c9\ud0c4\ud654\ub77c\uace0 \ud55c\ub2e4. \ud3c9\ud0c4\ud654\ub97c \ubaa8\ub450 \uc218\ud589\ud558\uace0 \ub098\uba74, \uac00\uc7a5 \ub192\uc740 \uacf3\uacfc \uac00\uc7a5 \ub0ae\uc740 \uacf3\uc758 \ucc28\uc774\uac00&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[3],"tags":[53],"aioseo_notices":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/mukgee.com\/index.php?rest_route=\/wp\/v2\/posts\/477"}],"collection":[{"href":"http:\/\/mukgee.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/mukgee.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/mukgee.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/mukgee.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=477"}],"version-history":[{"count":1,"href":"http:\/\/mukgee.com\/index.php?rest_route=\/wp\/v2\/posts\/477\/revisions"}],"predecessor-version":[{"id":612,"href":"http:\/\/mukgee.com\/index.php?rest_route=\/wp\/v2\/posts\/477\/revisions\/612"}],"wp:attachment":[{"href":"http:\/\/mukgee.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=477"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/mukgee.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=477"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/mukgee.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=477"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}