-
Notifications
You must be signed in to change notification settings - Fork 0
[BOJ] 1449. 수리공 항승 #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
deipanema
wants to merge
1
commit into
main
Choose a base branch
from
deipanema/23
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const filePath = process.platform === "linux" ? "/dev/stdin" : "./input.txt"; | ||
const input = require("fs").readFileSync(filePath).toString().split("\n"); | ||
|
||
// const [N, L] = input[0].split(" "); // N: 물이 새는 곳의 개수, L: 테이프 길이 | ||
const N = +input[0].split(" ")[0]; // 물이 새는 곳의 개수 | ||
const L = +input[0].split(" ")[1]; // 테이프 길이 | ||
|
||
const pos = input[1] | ||
.split(" ") | ||
.map(v => +v) | ||
.sort((a, b) => a - b); | ||
|
||
let current = 0; | ||
let end = 0; | ||
let result = 0; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 만약에 사용자가 물이 새는 곳이 4곳이라고 하고 기 위치를 3개만 입력했을 경우도 한번 생각 해보면 좋을듯 합니다. |
||
while (current < N) { | ||
if (end < pos[current]) { | ||
end = pos[current] + L - 0.5; | ||
result++; | ||
} | ||
current++; | ||
} | ||
|
||
console.log(result); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
음수값을 포함해서 정수형으로 정렬을 해줘야 하는 이유가 있을까요??? '문제에서 가장 왼쪽에서 정수 만큼 떨어진 거리만 물이샌다' 라고 하는데요.
nums.sort(function compareNumbers(a, b) { return a - b; });
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
음... 질문 이해가 잘 안되네용😂
혹시 적어놓으신 코드로 바꾸는 게 좋겠다는 말씀이신가요~?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아뇨 제가 적어놓은코드는 그냥 메모로 적어놓은코드입니다.
작성하신 코드중에
.sort((a,b) => a-b);
이 부분이 음수 가 나와도 정수형으로 변환해서 정렬해주는 부분으로 이해했는데 이부분이 굳이 꼭 필요한가 싶어서요