Skip to content

Commit

Permalink
59-9kyo-hwang
Browse files Browse the repository at this point in the history
  • Loading branch information
9kyo-hwang committed Aug 1, 2024
1 parent 1f9f82f commit 91fa21c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
38 changes: 38 additions & 0 deletions 9-kyo-hwang/Greedy/마법의 엘리베이터.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <vector>
#include <string>

using namespace std;

int solution(int Storey)
{
int Answer = 0;

while(Storey)
{
int Remainder = Storey % 10;
int Quotient = Storey / 10;

if(Remainder < 5) // 예: 54
{
Answer += Remainder; // 54 -> 50
}
else if(Remainder > 5) // 예: 16
{
++Quotient;
Answer += 10 - Remainder; // 16 -> 20
}
else
{
if(Quotient % 10 >= 5) // 예: 55 -> 60 / 25 -> 20
{
++Quotient;
}

Answer += Remainder;
}

Storey = Quotient;
}

return Answer;
}
3 changes: 2 additions & 1 deletion 9-kyo-hwang/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@
| 55차시 | 2024.7.09 | Simulation | [17144 미세먼지 안녕!](https://www.acmicpc.net/problem/16934) | [#202](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/202) |
| 56차시 | 2024.7.12 | Tree | [15681 트리와 쿼리](https://www.acmicpc.net/problem/15681) | [#204](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/204) |
| 57차시 | 2024.7.15 | Dynamic Programming | [17070 파이프 옮기기 1](https://www.acmicpc.net/problem/17070) | [#206](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/206) |
| 58차시 | 2024.7.29 | Trie | [14725 개미굴](https://www.acmicpc.net/problem/14725) | [#207](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/207) |
| 58차시 | 2024.7.29 | Trie | [14725 개미굴](https://www.acmicpc.net/problem/14725) | [#207](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/207) |
| 59차시 | 2024.8.01 | Greedy | [마법의 엘리베이터](https://school.programmers.co.kr/learn/courses/30/lessons/148653) | [#210](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/210) |

0 comments on commit 91fa21c

Please sign in to comment.