From 4f89ab1c51d8e8f9e9b2c12535c846739ee28b00 Mon Sep 17 00:00:00 2001 From: yenru0 Date: Tue, 16 Feb 2021 02:17:54 +0900 Subject: [PATCH] add lua & complete 14501, 14888 --- README.md | 1 + zeta_lua/completed/1000.lua | 2 ++ zeta_lua/completed/1001.lua | 2 ++ zeta_lua/stdin.txt | 1 + zeta_python/completed/14501.py | 21 ++++++++++++++++ zeta_python/completed/14888.py | 44 ++++++++++++++++++++++++++++++++++ 6 files changed, 71 insertions(+) create mode 100644 zeta_lua/completed/1000.lua create mode 100644 zeta_lua/completed/1001.lua create mode 100644 zeta_lua/stdin.txt create mode 100644 zeta_python/completed/14501.py create mode 100644 zeta_python/completed/14888.py diff --git a/README.md b/README.md index f2a476c..782ad32 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ yenru0 code storage C++ | cpp | .cpp Python | python | .py Kotlin | kotlin | .kt + Lua | lua | .lua ## stdin.txt 코딩의 편리함을 위한 `stdin.txt`! 이것은 매우 중요 especially 쓰다 C로 because 나 not 편함 diff --git a/zeta_lua/completed/1000.lua b/zeta_lua/completed/1000.lua new file mode 100644 index 0000000..33b5667 --- /dev/null +++ b/zeta_lua/completed/1000.lua @@ -0,0 +1,2 @@ +a,b =io.read("n", "n") +print(a + b) \ No newline at end of file diff --git a/zeta_lua/completed/1001.lua b/zeta_lua/completed/1001.lua new file mode 100644 index 0000000..e4eb2e9 --- /dev/null +++ b/zeta_lua/completed/1001.lua @@ -0,0 +1,2 @@ +a,b =io.read("n", "n") +print(a - b) \ No newline at end of file diff --git a/zeta_lua/stdin.txt b/zeta_lua/stdin.txt new file mode 100644 index 0000000..04f38ab --- /dev/null +++ b/zeta_lua/stdin.txt @@ -0,0 +1 @@ +3 7 \ No newline at end of file diff --git a/zeta_python/completed/14501.py b/zeta_python/completed/14501.py new file mode 100644 index 0000000..0f3d695 --- /dev/null +++ b/zeta_python/completed/14501.py @@ -0,0 +1,21 @@ +N = int(input()) +D = [tuple(map(int, input().split())) for i in range(N)] + +T = [] + + +def progress(day, cost): + if day == N: + T.append(cost) + return + elif day > N: + return + if D[day][0] == 1: + progress(day + 1, cost + D[day][1]) + else: + progress(day + D[day][0], cost + D[day][1]) + progress(day + 1, cost) + + +progress(0, 0) +print(max(T)) diff --git a/zeta_python/completed/14888.py b/zeta_python/completed/14888.py new file mode 100644 index 0000000..837fa62 --- /dev/null +++ b/zeta_python/completed/14888.py @@ -0,0 +1,44 @@ +N = int(input()) +ns = list(map(int, input().split())) +ops = list(map(int, input().split())) + +stack = [] + +traces = [] + +def calc(ind, a, b): + if ind == 0: + return a+b + elif ind == 1: + return a-b + elif ind == 2: + return a*b + elif ind == 3: + return int(a/b) + + +_ops = ops[:] +for i, v in enumerate(ops): + if v == 0: + pass + else: + _ops[i] = _ops[i] - 1 + stack.append((1, _ops, calc(i, ns[0], ns[1]))) + _ops = ops[:] + +while stack: + d, o, n = stack.pop() + if not any(o): + traces.append(n) + else: + _ops = o[:] + for i, v in enumerate(o): + if v == 0: + pass + else: + _ops[i] = _ops[i] - 1 + stack.append((d+1, _ops, calc(i, n, ns[d+1]))) + _ops = o[:] + +print(max(traces)) +print(min(traces)) \ No newline at end of file