From c41f4d35ebec3f89773050c5dbaf426171dd242a Mon Sep 17 00:00:00 2001 From: kim_yubin Date: Fri, 26 Oct 2018 19:04:21 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B6=94=EA=B0=80=20'Greedy=20Algorithm'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Greedy Algorithm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Greedy Algorithm diff --git a/Greedy Algorithm b/Greedy Algorithm new file mode 100644 index 0000000..a5bf442 --- /dev/null +++ b/Greedy Algorithm @@ -0,0 +1,16 @@ +a=[50, 5, 2] +an=56 +bn=54 +t=0 +ans=[] + +while 1: + if an < a[t]: + break + while an>a[t]: + ans.append(a[t]) + an = an - a[t] + t += 1 + +print(an) +print(ans) \ No newline at end of file