{"id":2234,"date":"2009-10-01T00:00:55","date_gmt":"2009-10-01T00:00:55","guid":{"rendered":"http:\/\/192.168.0.71:9090\/?p=1936"},"modified":"2009-10-01T00:00:55","modified_gmt":"2009-10-01T00:00:55","slug":"programming-challenges-%ec%97%ac%ed%96%89-the-trip","status":"publish","type":"post","link":"https:\/\/talsu.net\/?p=2234","title":{"rendered":"Programming Challenges &#8211; \uc5ec\ud589 (The Trip)"},"content":{"rendered":"<p><span style=\"font-size: 12pt; font-weight: bold;\"><a title=\"[http:\/\/programming-challenges.com\/pg.php?page=downloadproblem&amp;probid=110103&amp;format=html]\ub85c \uc774\ub3d9\ud569\ub2c8\ub2e4.\" target=\"_blank\" href=\"http:\/\/programming-challenges.com\/pg.php?page=downloadproblem&amp;probid=110103&amp;format=html\">\ubb38\uc81c &lt;- \ud074\ub9ad<\/a><\/span><\/p>\n<p>\ud558\uba74 \ud560\uc218\ub85d \ucc44\uc810 \ub85c\ubd07\uc774 \ubab9\uc2dc \uae4c\ub2e4\ub86d\ub2e4\ub294\uac83\uc744 \ub290\ub080\ub2e4.<\/p>\n<p>\ud035\uc815\ub82c.. \uc774\ub860\uc0c1\uc73c\ub85c\ub294 \uc54c\uace0 \uc788\uc9c0\ub9cc \uc9c1\uc811 \uad6c\ud604\ud558\ub2c8\uae4c \uc5ed\uc2dc \ud6a8\uc728\uc801\uc73c\ub85c \ud558\ub294\uac83\uc774 \ub9cc\ub9cc\uce58 \uc54a\ub2e4. \uacb0\uad6d \uc704\ud0a4 \ubc31\uacfc\uc5d0 \uc788\ub294\uac83\uc744 \ucc38\uace0 \ud588\ub2e4. \uc0ac\uc2e4 \uc81c\uacf5 \ub418\ub294 \ud568\uc218\ub97c \uc4f0\uba74 \ub418\uc9c0\ub9cc \uadf8\ub798\ub3c4 \uacf5\ubd80\ub2c8\uae4c..<\/p>\n<pre class=\"lang:c++ decode:true\">#include <iostream>\n#include <stdlib.h>\n#define MAX_STUDENT 1000\nusing namespace std;\n\nvoid qSort(int* arr, int left, int right) { \/\/\uae30\ubcf8 \uc81c\uacf5 \ub418\uc9c0\ub9cc... \uacf5\ubd80\ub97c \uc704\ud574\n    int pivot = arr[left];\n    int left_hold, right_hold;\n    left_hold = left;\n    right_hold = right;\n    while (left < right) {\n        while ((arr[right] >= pivot) && (left < right))\n            right--;\n        if (left != right) {\n            arr[left] = arr[right];\n            left++;\n        }\n        while ((arr[left] <= pivot) &#038;&#038; (left < right))\n            left++;\n        if (left != right) {\n            arr[right] = arr[left];\n            right--;\n        }\n    }\n    arr[left] = pivot;\n    pivot = left;\n    left = left_hold;\n    right = right_hold;\n    if (left < pivot)\n        qSort(arr, left, pivot - 1);\n    if (right > pivot)\n        qSort(arr, pivot + 1, right);\n}\nvoid quickSort(int* arr, int arr_size) {\n    qSort(arr, 0, arr_size - 1);\n}\nint main() {\n    int students[MAX_STUDENT];\n    int average, sum = 0, result = 0;\n    int numberOf1CentMore;\n    int numberOfStudent;\n    double temp;\n    while (scanf(\"%d\", &numberOfStudent) == 1) {\n        if (!numberOfStudent)\n            break;\n        for (int i = 0; i < numberOfStudent; ++i) {\n            scanf(\"%lf\", &#038;temp);\n            students[i] = (int) (temp * 100 + 0.5); \/\/integer\ub85c \ubcc0\ud658 \ud558\uba74\uc11c 0.5\ub97c \ub354\ud574 \uc62c\ub9bc!!\n            sum += students[i];\n        }\n\n        quickSort(students, numberOfStudent); \/\/\uc9c0\ubd88\ud55c \uc561\uc218 \uc21c\uc73c\ub85c \uc815\ub82c\n\n        average = sum \/ numberOfStudent; \/\/\ud3c9\uade0\uc744 \uad6c\ud558\uace0\n        numberOf1CentMore = sum % numberOfStudent; \/\/\ub098\uba38\uc9c0\ub294 \ub9ce\uc774 \ub0b8\uc0ac\ub78c\ub4e4\uc5d0\uac8c \ubd84\ubc30\n\n        for (int i = 0; i < numberOfStudent - numberOf1CentMore; ++i) {\n            result += abs(students[i] - average); \/\/\ucc28\uc561\uc758 \uc808\ub300\uac12 \ub204\uc801\n        }\n        for (int i = numberOfStudent - numberOf1CentMore; i < numberOfStudent; ++i) {\n            result += abs(students[i] - (average + 1)); \/\/\ub098\uba38\uc9c0\ub97c 1\uc529 \ub354\ud55c \ucc28\uc561\uc744 \ub204\uc801\n        }\n\n        result \/= 2;\n\n        printf(\"$%.2fn\", result \/ 100.0);\n\n        sum = 0;\n        result = 0;\n    }\n    return 0;\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\ubb38\uc81c &lt;- \ud074\ub9ad \ud558\uba74 \ud560\uc218\ub85d \ucc44\uc810 \ub85c\ubd07\uc774 \ubab9\uc2dc \uae4c\ub2e4\ub86d\ub2e4\ub294\uac83\uc744 \ub290\ub080\ub2e4. \ud035\uc815\ub82c.. \uc774\ub860\uc0c1\uc73c\ub85c\ub294 \uc54c\uace0 \uc788\uc9c0\ub9cc \uc9c1\uc811 \uad6c\ud604\ud558\ub2c8\uae4c \uc5ed\uc2dc \ud6a8\uc728\uc801\uc73c\ub85c \ud558\ub294\uac83\uc774 \ub9cc\ub9cc\uce58 \uc54a\ub2e4. \uacb0\uad6d \uc704\ud0a4 \ubc31\uacfc\uc5d0 \uc788\ub294\uac83\uc744 \ucc38\uace0 \ud588\ub2e4. \uc0ac\uc2e4 \uc81c\uacf5 \ub418\ub294 \ud568\uc218\ub97c \uc4f0\uba74 \ub418\uc9c0\ub9cc \uadf8\ub798\ub3c4 \uacf5\ubd80\ub2c8\uae4c.. #include #include #define MAX_STUDENT 1000 using namespace std; void qSort(int* arr, int left, int right) { \/\/\uae30\ubcf8 \uc81c\uacf5 \ub418\uc9c0\ub9cc&#8230; \uacf5\ubd80\ub97c [&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":[9],"tags":[49,203,208,265,385,443],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pXV5a-A2","_links":{"self":[{"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/posts\/2234"}],"collection":[{"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/talsu.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2234"}],"version-history":[{"count":0,"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/posts\/2234\/revisions"}],"wp:attachment":[{"href":"https:\/\/talsu.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2234"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/talsu.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2234"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/talsu.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2234"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}