HomeAboutMeBlogGuest
© 2025 Sejin Cha. All rights reserved.
Built with Next.js, deployed on Vercel
🤎
프론트엔드 데브코스 5기 교육생
/
🐥
김은수팀
/
🏆
10주차 : 기업 코테 딱대
/
3. 수열

3. 수열

고른 사람
민수
URL
https://www.acmicpc.net/problem/2491
난이도
실버4

다윤 풀이

민수 풀이

재현 풀이

송희 풀이

const fs = require("fs"); const filePath = process.platform === "linux" ? "/dev/stdin" : "./input.txt"; const [n, num] = fs.readFileSync(filePath).toString().trim().split("\n"); let nums = num.split(" "); let count = 0; if (n == 1) return console.log(1); const increse = (arr) => { for (i = 0; i < arr.length - 1; i++) { let tmpCount = 1; while (+arr[i] <= +arr[i + 1]) { i++; tmpCount++; } count = Math.max(count, tmpCount); if (i == arr.length - 1) return; } }; const decrese = (arr) => { for (i = 0; i < arr.length - 1; i++) { let tmpCount = 1; while (+arr[i] >= +arr[i + 1]) { i++; tmpCount++; } count = Math.max(count, tmpCount); if (i == arr.length - 1) return; } }; increse(nums); decrese(nums); console.log(count);

승민 풀이