κ°μΈκ³΅λΆ/Algorithm
[λ°±μ€][Node.js] 5532λ² : λ°©ν μμ
πλ°λ΄λ΄π
2021. 11. 17. 23:01
Algorithm
- λ°©ν μμ -
λ¬Έμ
μκ·Όμ΄λ μ΄λ±νκ΅μ λ€λ λ, λ°©ν μμ λ₯Ό λ¨λ€λ³΄λ€ λ¨Όμ 미리 νκ³ λ¨μ κΈ°κ°μ λμλ€. λ°©ν μμ λ μνκ³Ό κ΅μ΄ λ¬Έμ νκΈ°μ΄λ€.
λ°©νμ μ΄ LμΌ μ΄λ€. μνμ μ΄ Bνμ΄μ§, κ΅μ΄λ μ΄ Aνμ΄μ§λ₯Ό νμ΄μΌ νλ€. μκ·Όμ΄λ ν루μ κ΅μ΄λ₯Ό μ΅λ Cνμ΄μ§, μνμ μ΅λ Dνμ΄μ§ ν μ μλ€.
μκ·Όμ΄κ° κ²¨μΈ λ°©νλμ μμ λ₯Ό νμ§ μκ³ λ μ μλ μ΅λ λ μ μλ₯Ό ꡬνλ νλ‘κ·Έλ¨μ μμ±νμμ€.
μ μΆλ ₯ μμ
λ¬Έμ νκΈ°
let fs = require("fs");
let input = fs.readFileSync("/dev/stdin")
.toString()
.split("\n")
.map((el) => Number(el));
while (true) {
input[0]--;
input[1] -= input[3];
input[2] -= input[4];
if (input[1] <= 0 && input[2] <= 0) break;
}
console.log(input[0]);
λ°μν