Skip to content

Commit

Permalink
21-게임을-만든-동준이
Browse files Browse the repository at this point in the history
  • Loading branch information
minbr0ther committed Apr 3, 2022
1 parent 66986fd commit 3dac6ff
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
18 changes: 18 additions & 0 deletions 2022/greedy/19~24/21-게임을-만든-동준이/app.js
@@ -0,0 +1,18 @@
const fs = require('fs');
const filePath = process.platform === 'linux' ? '/dev/stdin' : './input.txt';
let input = fs.readFileSync(filePath).toString().trim().split('\n');

let [n, ...arr] = input;

n = Number(n);
arr = arr.map(Number).reverse();

let cnt = 0;

for (let i = 1; i < n; i++) {
if (arr[i - 1] <= arr[i]) {
cnt += arr[i] - arr[i - 1] + 1;
arr[i] = arr[i - 1] - 1;
}
}
console.log(cnt);
4 changes: 4 additions & 0 deletions 2022/greedy/19~24/21-게임을-만든-동준이/input.txt
@@ -0,0 +1,4 @@
3
5
5
5
18 changes: 18 additions & 0 deletions 2022/greedy/19~24/21-병든-나이트/app.js
@@ -0,0 +1,18 @@
const fs = require('fs');
const filePath = process.platform === 'linux' ? '/dev/stdin' : './input.txt';
let input = fs.readFileSync(filePath).toString().trim().split('\n');

let [n, ...arr] = input;

n = Number(n);
arr = arr.map(Number).reverse();

let cnt = 0;

for (let i = 1; i < n; i++) {
if (arr[i - 1] <= arr[i]) {
cnt += arr[i] - arr[i - 1] + 1;
arr[i] = arr[i - 1] - 1;
}
}
console.log(cnt);
4 changes: 4 additions & 0 deletions 2022/greedy/19~24/21-병든-나이트/input.txt
@@ -0,0 +1,4 @@
3
5
5
5

0 comments on commit 3dac6ff

Please sign in to comment.