문제https://www.acmicpc.net/problem/3085 정답 코드const fs = require("fs");const filePath = process.platform === "linux" ? "/dev/stdin" : "./input.txt";const input = fs.readFileSync(filePath).toString().trim().split("\n");const checkMaxCount = (candy, maxCount) => { // 행체크 for (let row of candy) { let count = 1; for (let i = 0; i index !== 0).map((c) => c.split("")); let maxCount = 0; for (..
문제https://www.acmicpc.net/problem/2309 정답 코드const fs = require("fs");const filePath = process.platform === "linux" ? "/dev/stdin" : "./input.txt";const input = fs .readFileSync(filePath) .toString() .trim() .split("\n") .map((num) => Number(num));function solution(input) { let result; const sum = input.reduce((acc, cur) => { return acc + cur; }, 0); // 이중 for문으로 두 명의 난쟁이를 찾는다 for (l..
문제https://www.acmicpc.net/problem/10799 정답 코드const fs = require("fs");const filePath = process.platform === "linux" ? "/dev/stdin" : "./input.txt";const input = fs.readFileSync(filePath).toString().trim();function solution(input) { const stack = []; let result = 0; // 레이저인지 막대기의 끝인지 구분하기 위한 변수 let prev = ""; for (let i = 0; i "(" 가 나오면 스택에 추가")" 가 나오면 스택에서 제거, 이전 문자가 "(" 이면 레이저 ")" 이면 막대기의 ..
문제https://www.acmicpc.net/problem/2525 정답 코드const fs = require("fs");const filePath = process.platform === "linux" ? "/dev/stdin" : "./input.txt";const input = fs.readFileSync(filePath).toString().trim().split("\n");const getCookingTime = (hour, minutes, time) => { let newMinutes = minutes + time; let newHour = hour; if (newMinutes > 59) { newHour += parseInt(newMinutes / 60); newMinute..
문제https://www.acmicpc.net/problem/10866 정답 코드const fs = require("fs");const filePath = process.platform === "linux" ? "/dev/stdin" : "./input.txt";const input = fs.readFileSync(filePath).toString().trim().split("\n");class Deque { #array; constructor() { this.#array = []; } // 정수 x 를 덱의 앞에 넣는다. pushFront(value) { this.#array.unshift(value); } // 정수 x 를 덱의 뒤에 넣는다. pushBack(value) { ..
문제https://www.acmicpc.net/problem/14681 정답 코드해당 문제를 기존에 사용하던 방식대로 fs 모듈을 활용해 입력을 처리했더니, Error: EACCES: permission denied 라는 런타임 오류가 발생했다. 알고보니 문제마다 입력받는 방식에 차이가 있을 수 있나보다. 🧐 이 문제는 fs 모듈 대신 readline 모듈을 사용하거나 readFileSync(0) 을 사용해야한다. readline 모듈 방식const readline = require("readline");const rl = readline.createInterface({ input: process.stdin, output: process.stdout,});const getQuadrant = (x, ..
내 블로그 - 관리자 홈 전환 |
Q
Q
|
---|---|
새 글 쓰기 |
W
W
|
글 수정 (권한 있는 경우) |
E
E
|
---|---|
댓글 영역으로 이동 |
C
C
|
이 페이지의 URL 복사 |
S
S
|
---|---|
맨 위로 이동 |
T
T
|
티스토리 홈 이동 |
H
H
|
단축키 안내 |
Shift + /
⇧ + /
|
* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.