Skip to content
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

12-mong3125 #41

Merged
merged 1 commit into from
Apr 10, 2024
Merged

12-mong3125 #41

merged 1 commit into from
Apr 10, 2024

Conversation

mong3125
Copy link
Collaborator

@mong3125 mong3125 commented Mar 28, 2024

πŸ”— 문제 링크

기타 레슨

βœ”οΈ μ†Œμš”λœ μ‹œκ°„

λͺ» ν’€κ³  아이디어 λ΄„
보고 λ‚˜μ„œ 30λΆ„

✨ μˆ˜λ„ μ½”λ“œ

문제 μ„€λͺ…

image
μž…λ ₯으둜
N M
l[0], l[1], l[2]...
μ΄λ ‡κ²Œ λ“€μ–΄μ˜€λŠ”λ° N은 l의 길이이고 M은 λ ˆμ½”λ“œ κ°œμˆ˜μž…λ‹ˆλ‹€. l은 κ°•μ˜μ˜μƒ κΈΈμ΄μ΄κ³ μš”.

κ°•μ˜λŠ” μ—°μ†ν•΄μ„œ μ €μž₯을 ν•΄μ•Όν•©λ‹ˆλ‹€. 이 λ•Œ λ ˆμ½”λ“œ κ°œμˆ˜λ‚΄λ‘œ μ €μž₯ν•˜κΈ° μœ„ν•΄μ„œ λ ˆμ½”λ“œ μ΅œμ†Œ 길이λ₯Ό κ΅¬ν•˜λŠ” λ¬Έμ œμž…λ‹ˆλ‹€.

λ¬Έμ œλŠ” 긴데 μ΄ν•΄ν•˜λ©΄ μ΄λ ‡κ²Œ κ°„λ‹¨ν•˜κ²Œ 이해할 수 μžˆμŠ΅λ‹ˆλ‹€.

* 정닡은 0κ³Ό λͺ¨λ“  κ°•μ˜μ‹œκ°„μ„ ν•©ν•œ μ‹œκ°„ 사이에 μžˆμ„κ²ƒμ΄λ‹€.
* 0κ³Ό ν•©ν•œ μ‹œκ°„ 사이에 μ‘΄μž¬ν•˜λŠ” 값을 μ°ΎκΈ°μœ„ν•΄ μ΄λΆ„νƒμƒ‰μœΌλ‘œ μ°ΎλŠ”λ‹€.

minBlue(λ²”μœ„ μ‹œμž‘, λ²”μœ„ 끝) {
    λ²”μœ„ 끝이 μ‹œμž‘λ³΄λ‹€ μž‘μœΌλ©΄ μ΅œλŒ€κ°’μ„ λ°˜ν™˜ν•œλ‹€.
    
    μ‹œμž‘κ³Ό 끝의 쀑간값을 κ΅¬ν•œλ‹€.
    μ€‘κ°„κ°’μœΌλ‘œ λ…Ήν™”κ°€ κ°€λŠ₯ν•œμ§€ κ²€μ‚¬ν•œλ‹€.
    κ°€λŠ₯ν•˜λ‹€λ©΄ μ‹œμž‘λΆ€ν„° 쀑간-1 λ²”μœ„μ—μ„œ λ‹€μ‹œ μ°Ύκ³ , μ—†λ‹€λ©΄ 쀑간값을 λ°˜ν™˜ν•œλ‹€.
    λΆˆκ°€λŠ₯ν•˜λ‹€λ©΄ 쀑간+1λΆ€ν„° 끝사이 λ²”μœ„μ—μ„œ μ°ΎλŠ”λ‹€.
}

πŸ“š μƒˆλ‘­κ²Œ μ•Œκ²Œλœ λ‚΄μš©

  • 정닡이 aλΆ€ν„° b사이에 있고 쑰건을 λ§Œμ‘±μ‹œν‚€λŠ” 값을 μ°ΎλŠ” λ¬Έμ œμΌλ•Œ μ΄λΆ„νƒμƒ‰μœΌλ‘œ ν•΄κ²°ν•  수 μžˆλ‹€.

@tgyuuAn tgyuuAn removed the request for review from kjs254 March 28, 2024 16:49
@YIM2UL2ET YIM2UL2ET changed the title BOJ1243_이진탐색 java solution 12-mong3125 Mar 29, 2024
Copy link
Collaborator

@YIM2UL2ET YIM2UL2ET left a comment

Choose a reason for hiding this comment

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

이거 λͺ‡ 일 λ™μ•ˆ κ³ λ―Όν•˜λ‹€κ°€ κ²°κ΅­ λͺ» ν’€μ—ˆλŠ”λ° 이뢄탐색 μ΄μ—ˆκ΅°μš”..
λŒ€μ²΄ 이런 풀이λ₯Ό μ–΄λ–»κ²Œ ν•˜λŠ” 건지 μ‹Άμ–΄μ„œ 계속 μ½μ–΄λ³΄κ²Œ λ˜λ„€μš”.
ν•œ 수 μ–»μ–΄κ°‘λ‹ˆλ‹€. μˆ˜κ³ ν•˜μ…¨μŠ΅λ‹ˆλ‹€.

Copy link
Member

@kjs254 kjs254 left a comment

Choose a reason for hiding this comment

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

μ†μœΌλ‘œ 풀기도 μ–΄λ €μš΄ κ±Έ μ–΄λ–»κ²Œ μ½”λ“œλ‘œ κ΅¬ν˜„ν• μ§€ 막연해 λ³΄μ˜€λŠ”λ° 이뢄탐색을 μ΄μš©ν•˜λ©΄ κ°„λ‹¨ν•˜κ³  λΉ λ₯΄κ²Œ κ΅¬ν˜„ν•  수 μžˆκ΅°μš”.

μ΄λΆ„νƒμƒ‰λ§Œ 생각해낸닀면 mid κ°’μœΌλ‘œ λ…Ήν™”κ°€ κ°€λŠ₯ν•œμ§€ νŒλ…ν•˜λŠ” 쑰건을 κ΅¬ν˜„ν•˜λŠ” 것이 이 문제의 ν•΅μ‹¬μœΌλ‘œ λ³΄μž…λ‹ˆλ‹€.

Comment on lines +49 to +64
public static boolean can(int blueray) {
int count = M;
int i = 0;
int stack = blueray;
while (count > 0) {
while (stack - lectures[i] > 0) {
if (i == N) return true;
stack -= lectures[i];
i++;
}

stack = blueray;
count--;
}

return false;
Copy link
Member

Choose a reason for hiding this comment

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

μœ„μ˜ can() ν•¨μˆ˜λ‘œ mid μ‚¬μ΄μ¦ˆλ‘œ λ…Ήν™”κ°€ κ°€λŠ₯ν•œμ§€ νŒλ…ν•˜λŠ”κ±Έλ‘œ λ³΄μž…λ‹ˆλ‹€.
mid 값을 담은 stackμ—μ„œ κ°•μ˜μ‹œκ°„μ„ ν•˜λ‚˜μ”© λΉΌκ°€λ©΄μ„œ λͺ¨λ“  κ°•μ˜κ°€ M개의 λΈ”λ£¨λ ˆμ΄μ— λ‹΄κΈΈ 수 μžˆλŠ”μ§€ νŒλ…ν•˜λŠ”κ²ƒμœΌλ‘œ μ΄ν•΄ν•˜λ©΄ λ κΉŒμš”?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

λ„€ λ§žμŠ΅λ‹ˆλ‹€!

@mong3125 mong3125 removed the request for review from rivkms April 10, 2024 14:27
@mong3125 mong3125 merged commit b75b28a into main Apr 10, 2024
1 check passed
@mong3125 mong3125 deleted the 12-mong3125 branch April 10, 2024 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants