{"id":34106,"date":"2024-11-01T09:24:11","date_gmt":"2024-11-01T09:24:11","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=34106"},"modified":"2024-11-01T10:58:35","modified_gmt":"2024-11-01T10:58:35","slug":"c-coding-test-course-calculating-atm-withdrawal-time-2","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/34106\/","title":{"rendered":"C++ Coding Test Course, Calculating ATM Withdrawal Time"},"content":{"rendered":"<p><body><\/p>\n<p>\n    In recent years, algorithm and problem-solving skills have become important evaluation factors in the IT industry. As an extension of this trend, many companies are assessing candidates&#8217; abilities through coding tests.<br \/>\n    In this article, we aim to enhance basic algorithm problem-solving skills using C++ by solving the &#8216;Calculate ATM Withdrawal Time&#8217; problem.\n<\/p>\n<h2>Problem Description<\/h2>\n<p>\n    In the ATM, the time taken to process a withdrawal request varies for each user.<br \/>\n    For example, if one user requests a withdrawal after 1 minute, that time is fully processed, and the user can withdraw after 1 minute.<br \/>\n    If multiple users request withdrawals simultaneously, the requests are processed in FIFO (First-In-First-Out) order, meaning that the first requested user is served first.\n<\/p>\n<p>\n    Given the order of user requests and the time required for each request, write a program that calculates and outputs the total time needed for all users to complete their withdrawals.\n<\/p>\n<h3>Input Format<\/h3>\n<ul>\n<li>The first line contains an integer N (1 \u2264 N \u2264 1000) representing the number of withdrawal requests.<\/li>\n<li>The second line contains the times taken for the withdrawal requests, given as N integers separated by spaces. (1 \u2264 each request time \u2264 100)<\/li>\n<\/ul>\n<h3>Output Format<\/h3>\n<ul>\n<li>Output the total time taken for all users to complete their withdrawals.<\/li>\n<\/ul>\n<h4>Example Input<\/h4>\n<pre>\n5\n3 1 4 3 2\n<\/pre>\n<h4>Example Output<\/h4>\n<pre>\n32\n<\/pre>\n<h2>Problem Solving Process<\/h2>\n<p>\n    The key to solving the problem is to sum up the times needed for each user to complete their withdrawal.<br \/>\n    In this process, we must consider the order in which the requests are processed. Since requests are handled in FIFO order, the first requested user passes first.<br \/>\n    We follow the steps below to solve this problem.\n<\/p>\n<h3>Step 1: Read Input Values<\/h3>\n<p>\n    First, we need to read the number of requests and the request times from the user. In C++, data can be read through standard input.\n<\/p>\n<pre><code>\n#include &lt;iostream&gt;\n#include &lt;vector&gt;\n\nusing namespace std;\n\nint main() {\n    int N;\n    cin &gt;&gt; N;\n\n    vector&lt;int&gt; times(N);\n    for (int i = 0; i &lt; N; i++) {\n        cin &gt;&gt; times[i];\n    }\n\n    return 0;\n}\n<\/code><\/pre>\n<h3>Step 2: Calculate Total Time<\/h3>\n<p>\n    Each user&#8217;s request time incurs a waiting time due to the requests being processed before them.<br \/>\n    Therefore, the time taken for each user to complete their request must be the sum of their request time and the request times of previous users.<br \/>\n    This way, from the second user onward, the waiting time will be equal to the first user&#8217;s request time.\n<\/p>\n<pre><code>\n#include &lt;iostream&gt;\n#include &lt;vector&gt;\n\nusing namespace std;\n\nint main() {\n    int N;\n    cin &gt;&gt; N;\n\n    vector&lt;int&gt; times(N);\n    for (int i = 0; i &lt; N; i++) {\n        cin &gt;&gt; times[i];\n    }\n\n    int totalTime = 0;\n    int currentTime = 0;\n\n    for (int i = 0; i &lt; N; i++) {\n        currentTime += times[i]; \/\/ Add the request time to the current time\n        totalTime += currentTime; \/\/ Add the current time to the total time\n    }\n\n    cout &lt;&lt; totalTime &lt;&lt; endl; \/\/ Output the final total time\n\n    return 0;\n}\n<\/code><\/pre>\n<h3>Step 3: Code Explanation<\/h3>\n<p>\n    The first part of the code is for reading data from standard input.<br \/>\n    <code>vector&lt;int&gt; times(N);<\/code> creates a dynamic array to store the request times.<br \/>\n    Secondly, a variable called <code>currentTime<\/code> accumulates the time up to the current point.<br \/>\n    Each time a user&#8217;s request comes in, the request time for that request is added to <code>currentTime<\/code>, and this is accumulated in the total time <code>totalTime<\/code>.\n<\/p>\n<h2>Complete Code<\/h2>\n<pre><code>\n#include &lt;iostream&gt;\n#include &lt;vector&gt;\n\nusing namespace std;\n\nint main() {\n    int N;\n    cin &gt;&gt; N; \/\/ Input the number of requests\n\n    vector&lt;int&gt; times(N); \/\/ Declare a vector to hold the request times\n    for (int i = 0; i &lt; N; i++) {\n        cin &gt;&gt; times[i]; \/\/ Input the time for each request\n    }\n\n    int totalTime = 0; \/\/ Accumulate the total request times\n    int currentTime = 0; \/\/ Accumulate the current processing time\n\n    for (int i = 0; i &lt; N; i++) {\n        currentTime += times[i]; \/\/ Add the request time\n        totalTime += currentTime; \/\/ Add to the total time so far\n    }\n\n    cout &lt;&lt; totalTime &lt;&lt; endl; \/\/ Output the final total time\n\n    return 0;\n}\n<\/code><\/pre>\n<h2>Conclusion<\/h2>\n<p>\n    By solving problems like this, we can enhance our understanding of algorithms and the C++ programming language.<br \/>\n    It will help cultivate basic problem-solving skills that can be useful in coding tests or algorithm competitions.<br \/>\n    It is important to build skills through various problems and prepare for interviews, and we hope this course has helped develop that foundation.\n<\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In recent years, algorithm and problem-solving skills have become important evaluation factors in the IT industry. As an extension of this trend, many companies are assessing candidates&#8217; abilities through coding tests. In this article, we aim to enhance basic algorithm problem-solving skills using C++ by solving the &#8216;Calculate ATM Withdrawal Time&#8217; problem. Problem Description In &hellip; <a href=\"https:\/\/atmokpo.com\/w\/34106\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;C++ Coding Test Course, Calculating ATM Withdrawal Time&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[111],"tags":[],"class_list":["post-34106","post","type-post","status-publish","format-standard","hentry","category-c-coding-test-tutorials-2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>C++ Coding Test Course, Calculating ATM Withdrawal Time - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/atmokpo.com\/w\/34106\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C++ Coding Test Course, Calculating ATM Withdrawal Time - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"In recent years, algorithm and problem-solving skills have become important evaluation factors in the IT industry. As an extension of this trend, many companies are assessing candidates&#8217; abilities through coding tests. In this article, we aim to enhance basic algorithm problem-solving skills using C++ by solving the &#8216;Calculate ATM Withdrawal Time&#8217; problem. Problem Description In &hellip; \ub354 \ubcf4\uae30 &quot;C++ Coding Test Course, Calculating ATM Withdrawal Time&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/34106\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:24:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T10:58:35+00:00\" \/>\n<meta name=\"author\" content=\"root\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:site\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"root\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"4\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/34106\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/34106\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"C++ Coding Test Course, Calculating ATM Withdrawal Time\",\"datePublished\":\"2024-11-01T09:24:11+00:00\",\"dateModified\":\"2024-11-01T10:58:35+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/34106\/\"},\"wordCount\":485,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"C++ Coding Test Tutorials\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/34106\/\",\"url\":\"https:\/\/atmokpo.com\/w\/34106\/\",\"name\":\"C++ Coding Test Course, Calculating ATM Withdrawal Time - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:24:11+00:00\",\"dateModified\":\"2024-11-01T10:58:35+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/34106\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/34106\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/34106\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C++ Coding Test Course, Calculating ATM Withdrawal Time\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/atmokpo.com\/w\/#website\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/atmokpo.com\/w\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"contentUrl\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"width\":400,\"height\":400,\"caption\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\"},\"image\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/bebubo4\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\",\"name\":\"root\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"caption\":\"root\"},\"sameAs\":[\"http:\/\/atmokpo.com\/w\"],\"url\":\"https:\/\/atmokpo.com\/w\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"C++ Coding Test Course, Calculating ATM Withdrawal Time - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/atmokpo.com\/w\/34106\/","og_locale":"ko_KR","og_type":"article","og_title":"C++ Coding Test Course, Calculating ATM Withdrawal Time - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"In recent years, algorithm and problem-solving skills have become important evaluation factors in the IT industry. As an extension of this trend, many companies are assessing candidates&#8217; abilities through coding tests. In this article, we aim to enhance basic algorithm problem-solving skills using C++ by solving the &#8216;Calculate ATM Withdrawal Time&#8217; problem. Problem Description In &hellip; \ub354 \ubcf4\uae30 \"C++ Coding Test Course, Calculating ATM Withdrawal Time\"","og_url":"https:\/\/atmokpo.com\/w\/34106\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:24:11+00:00","article_modified_time":"2024-11-01T10:58:35+00:00","author":"root","twitter_card":"summary_large_image","twitter_creator":"@bebubo4","twitter_site":"@bebubo4","twitter_misc":{"\uae00\uc4f4\uc774":"root","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"4\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/34106\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/34106\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"C++ Coding Test Course, Calculating ATM Withdrawal Time","datePublished":"2024-11-01T09:24:11+00:00","dateModified":"2024-11-01T10:58:35+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/34106\/"},"wordCount":485,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["C++ Coding Test Tutorials"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/34106\/","url":"https:\/\/atmokpo.com\/w\/34106\/","name":"C++ Coding Test Course, Calculating ATM Withdrawal Time - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:24:11+00:00","dateModified":"2024-11-01T10:58:35+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/34106\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/34106\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/34106\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"C++ Coding Test Course, Calculating ATM Withdrawal Time"}]},{"@type":"WebSite","@id":"https:\/\/atmokpo.com\/w\/#website","url":"https:\/\/atmokpo.com\/w\/","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","description":"","publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/atmokpo.com\/w\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/atmokpo.com\/w\/#organization","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","url":"https:\/\/atmokpo.com\/w\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/","url":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","contentUrl":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","width":400,"height":400,"caption":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8"},"image":{"@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/bebubo4"]},{"@type":"Person","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7","name":"root","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","caption":"root"},"sameAs":["http:\/\/atmokpo.com\/w"],"url":"https:\/\/atmokpo.com\/w\/author\/root\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/34106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/comments?post=34106"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/34106\/revisions"}],"predecessor-version":[{"id":34107,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/34106\/revisions\/34107"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=34106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=34106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=34106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}