Skip to content

Commit 80e6fcc

Browse files
[BOJ] 32200 항해 (S5)
1 parent 76bf4df commit 80e6fcc

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

서정우/11주차/260313.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const fs = require("fs");
2+
const { kill } = require("process");
3+
const filePath = process.platform === "linux" ? "/dev/stdin" : "./서정우/input.txt";
4+
const input = fs
5+
.readFileSync(filePath)
6+
.toString()
7+
.trim()
8+
.split("\n")
9+
.map((el) => el.trim());
10+
11+
const [N, X, Y] = input[0].split(" ").map(Number);
12+
const sandwiches = input[1].split(" ").map(Number);
13+
14+
// N = sandwiches count
15+
// X = 최소
16+
// Y = 최대
17+
18+
let kkini = 0;
19+
let left = 0;
20+
21+
sandwiches.forEach((sandwich) => {
22+
if (X <= sandwich) {
23+
const kkinies = Math.floor(sandwich / X);
24+
const maxEat = kkinies * Y;
25+
const eaten = Math.min(sandwich, maxEat);
26+
const wasted = sandwich - eaten;
27+
left += wasted;
28+
kkini += kkinies;
29+
} else {
30+
left += sandwich;
31+
}
32+
});
33+
console.log(kkini);
34+
console.log(left);

서정우/input.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
10 10
1+
6 10 12
2+
11 10 17 5 23 28

0 commit comments

Comments
 (0)