Skip to content

Conversation

choyunju
Copy link
Contributor

@choyunju choyunju commented May 6, 2025

✅ 문제번호 | 문제이름 | 난이도: 난이도 | 유형: 유형

📝 문제 설명

간단한 문제 요약

💡 풀이 설명

  • 핵심 아이디어 요약
  • 시간복잡도, 어려웠던 점, 공부한 점 등 자유롭게

@choyunju choyunju requested a review from k0000k May 6, 2025 05:10
@choyunju choyunju self-assigned this May 6, 2025
@choyunju choyunju changed the title Choyunju [ADD] choyunju 12주차 May 6, 2025
Copy link
Member

@k0000k k0000k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다!!

Comment on lines +39 to +43
count += diffDistance[i]/mid;
// 0으로 나누어 떨어진 경우 이미 휴게소가 1개 지어진 경우이므로 -1을 해준다.
if(diffDistance[i] % mid == 0) {
count--;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

엇ㅋㅋㅋ 저는 이거를 안될때까지 뺄셈하도록 했는데 나눗셈이라는 똑똑한 방법이...

Comment on lines +25 to +44
public static void binary_search(int start, int end) {
while(start < end) {
int diff = arr[start] + arr[end];
if(min > Math.abs(diff)) {
min = Math.abs(diff);
a = arr[start];
b = arr[end];
}
//두 용액의 합이 음수인 경우
if(diff < 0) {
start++;
}
//두 용액의 합이 양수인 경우
else if(diff > 0){
end--;
}
else {
break;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 세상에.. 이렇게하면 이분탐색으로 풀리는군요! 이걸 못떠올려서 절댓값 순으로 정렬해놓고 인접한 값들만 전부 비교했습니다... 😢

Comment on lines +22 to +24
} else {
isFlag = true;
break;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그냥 여기서 프린트하고 return; 해버리면 플래그를 안써도 깔끔하게 만들수 있습니다 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants