-
Notifications
You must be signed in to change notification settings - Fork 1
Conversation
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.
틀린 접근이었지만 그래도 의미있는 접근이었다고 생각합니다! 저도 아직 dp 문제가 진짜 머리 아프고 힘들지만 회고에 써주신 내용처럼 뭔가 이상하다 싶으면 접근법을 아예 바꾸려고 시도하면 조금 더 맞는 방향으로 생각할 확률이 올라가더라고요! 고생하셨습니다 도현님!
|
||
- 틀린 풀이 | ||
- 고르는 숫자의 개수(n) 에 대한 dp 테이블을 만들고 값으로는 최대값을 넣어보자 | ||
- 여러 예제를 만들어본 결과 배열 내 최대값은 고정으로 들어가는 것 같음 |
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.
이 가정이 틀린 풀이가 나온 가장 큰 이유가 아닐까 싶습니다.
[99, -1, -99, 98]
이 예제에서는 제일 큰 수 99가 배열에 수열에 포함되면 안되니까요!
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.
@zsmalla 으으음 제일 큰 수 99 딱 하나를 고르면 되기 때문에 결국 제일 큰 수가 배열에 포함되는 것이 아닐까요?!
제 기존 풀이로는 max(dp)
의 결과로 dp[1] = max(arr)
이 뽑히긴 합니다..!
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.
@zsmalla 으으음 제일 큰 수 99 딱 하나를 고르면 되기 때문에 결국 제일 큰 수가 배열에 포함되는 것이 아닐까요?! 제 기존 풀이로는
max(dp)
의 결과로dp[1] = max(arr)
이 뽑히긴 합니다..!
헐 맞네요 그 생각을 못했습니다 ㅎㅎ.. 그럼 저 경우는 해당 안될 것 같고, [99 -1 60 61] 이런 경우??
- 여러 예제를 만들어본 결과 배열 내 최대값은 고정으로 들어가는 것 같음 | ||
- dp[1] 에 가장 큰 수를 넣으면 가장 큰 수를 고정으로 넣은 것과 같음 | ||
- 따라서 고르는 숫자의 개수가 1개 늘어나면 왼쪽에 하나 추가한거랑 오른쪽에 하나 추가한거 비교해서 더 큰것으로 선택 | ||
- 의사 코드 (점화식?) |
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.
고생하셨습니다 도현님 스터디 때 기존의 접근 방식에 대해서 설명해주시면 같이 반례들을 더 찾을 수 있을 것 같습니다!
- 그냥 왼쪽부터 순회하며 이전값 + 현재값이 더 크면 연속합 갱신해주고, 현재값이 더 크면 이전 합들을 다 버리고 새로 시작하면 됨 | ||
|
||
회고 | ||
- DP 문제는 테이블 설정 또는 점화식 접근을 잘 못하는 순간 완전 잘못된 방향으로 가는 것 같다 |
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.
너무 공감됩니다... 이번 문제는 저도 운좋게 풀이 할 수 있었지만 다른 문제들은 그게 너무 어려운 것 같아요 ㅠㅠ
|
||
inputs = sys.stdin.readline | ||
n = int(inputs()) | ||
arr = list(map(int, inputs().rstrip().split())) |
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.
split()을 사용하실 때는 whitespace가 모두 사라져서 rstrip은 안 써주어도 될 것 같습니다!
PR Summary
풀이시간
접근법
회고
ISSUE NUMBER