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

16-seongwon030 #66

Merged
merged 2 commits into from
Jul 12, 2024
Merged

16-seongwon030 #66

merged 2 commits into from
Jul 12, 2024

Conversation

seongwon030
Copy link
Collaborator

@seongwon030 seongwon030 commented Jul 4, 2024

πŸ”— 문제 링크

연속합

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

1μ‹œκ°„

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

n = int(input())
m = list(map(int,input().split()))

for i in range(1,n):
  m[i] = max(m[i], m[i]+m[i-1])
print(max(m))

ν…ŒμŠ€νŠΈμΌ€μ΄μŠ€λ₯Ό λ³΄λ©΄μ„œ 처음 μƒκ°ν–ˆλ˜ 것은 연속합이 μŒμˆ˜κ°€ λ‚˜μ˜¬ λ•ŒκΉŒμ§€ 더해주고 더할 λ•Œλ§ˆλ‹€ μ΅œλŒ€κ°’μ„ κ°±μ‹ ν•˜λŠ” 방식을 μƒκ°ν–ˆμ—ˆλŠ”λ° 그러렀면 경우의 μˆ˜κ°€ λ„ˆλ¬΄ 많이 λ°œμƒν–ˆλ‹€.

ν•΄κ²°

일일이 더할 값을 μ €μž₯해쀄 ν•„μš”μ—†μ΄ κ³„μ†ν•΄μ„œ κ°±μ‹ ν•˜λ©΄ λœλ‹€.
max(ν˜„μž¬ μš”μ†Œ, ν˜„μž¬μš”μ†Œ+μ΄μ „μš”μ†Œ)둜 λ°°μ—΄μ˜ 값을 계속 κ°±μ‹ ν•΄μ€€λ‹€. λ§ˆμ§€λ§‰μ—λŠ” μƒˆλ‘œ κ°±μ‹ λœ m리슀트λ₯Ό maxλ₯Ό μ¨μ„œ μ΅œλŒ€κ°’μ„ ꡬ해쀀닀.

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

μ½”λ“œλŠ” κ°„λ‹¨ν•˜μ§€λ§Œ λ©”λͺ¨λΌμ΄μ§•μ„ κ°€μ§€λŠ” dp의 μ •μ„λ¬Έμ œ μ˜€λ˜ 것 κ°™μŠ΅λ‹ˆλ‹€.

Copy link
Collaborator

@yuyu0830 yuyu0830 left a comment

Choose a reason for hiding this comment

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

μ•„μ£Ό κ°„κ²°ν•œ ν•΄κ²° 방식에 κ°„κ²°ν•œ μ½”λ“œ.. 이건 κΉ”λ”ν•΄μ„œ μ’‹λ„€μš” γ…Žγ…Ž m λ°°μ—΄ 없이 int ν•˜λ‚˜μ”© λ°›μ•„μ„œ 쑰금 더 짧게 λ§Œλ“€ 수 μžˆμ„ 것 같기도 ν•˜λ„€μš” γ…Žγ…Ž try?

Copy link
Collaborator

@InSange InSange left a comment

Choose a reason for hiding this comment

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

문제λ₯Ό 보자마자 DPκ΅¬λ‚˜ λ°”λ‘œ νŒŒμ•…ν–ˆμŠ΅λ‹ˆλ‹€.. 이제 μ–΄λŠμ •λ„ 문제λ₯Ό λ³΄λŠ” 눈이 생긴걸지도.?
ν•˜μ§€λ§Œ 이전 값을 λ”ν•΄μ„œ λΉ„κ΅ν•˜λŠ” 것은 λ°”λ‘œ λ– μ˜€λ₯΄μ§€λŠ” μ•Šλ”κ΅°μš”. 값을 더할 λ•Œ ν•˜ν–₯λ˜λŠ” μ‹œμ μ€ 곧 - + μž„μœΌλ‘œ ν•΄λ‹Ή 뢀뢄을 잘 νŒŒμ•…ν•΄μ„œ 풀은 것 κ°™μŠ΅λ‹ˆλ‹€.
μ–΄λ–€ λ¬Έμ œμ—μ„œλŠ” 였히렀 이런 방식이 독이 λ˜λŠ” κ²½μš°λ„ μžˆλŠ”λ° μ–΄λ–€ λ¬Έμ œμ˜€λŠ”μ§€ 기얡이 μ•ˆλ‚˜λ„€μš”... λ‹€μŒμ— 찾으면 μ˜¬λ €λ³΄λ„λ‘ ν•˜κ² μ‹¬λ‹€

@seongwon030 seongwon030 merged commit d1aa6c6 into main Jul 12, 2024
1 check passed
@seongwon030 seongwon030 deleted the 16-seongwon030 branch July 12, 2024 09:56
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