-
Notifications
You must be signed in to change notification settings - Fork 0
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
[그리디 알고리즘] 9월 25일 #6
base: main
Are you sure you want to change the base?
The head ref may contain hidden characters: "06_\uADF8\uB9AC\uB514_\uC54C\uACE0\uB9AC\uC998"
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.
[그리디 알고리즘 구현 코드 리뷰 완료]
18111 (P3)
자신만의 코드로 작성해주셨네요! 수고하셨습니다!
vector<int> answer=mine(g, B); | ||
|
||
//출력 | ||
cout<<answer[0]<<" "<<answer[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.
endl을 붙여 주시면 좋을 것 같네요!
ans[0]=s; | ||
ans[1]=g[0]; | ||
|
||
return ans; |
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.
pair로 다뤄 주셨어도 좋을 것 같아요!
if(insert_count<=delete_count){ | ||
if(insert_count<=B){ | ||
for(int i=0; i<g.size(); i++){ | ||
if(g[i]==min){ | ||
g[i]++; | ||
s++; | ||
B--; | ||
} | ||
} | ||
} | ||
else{ | ||
for(int i=0; i<g.size(); i++){ | ||
if(g[i]==max){ | ||
g[i]--; | ||
s+=2; | ||
B++; | ||
} | ||
} | ||
} | ||
} | ||
else{ | ||
for(int i=0; i<g.size(); i++){ | ||
if(g[i]==max){ | ||
g[i]--; | ||
s+=2; | ||
B++; | ||
} | ||
} | ||
} |
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.
[그리디 알고리즘 코드 리뷰 완료]
1213(P3), 17451(P3)
안녕하세요 한선님! 코드 리뷰 완료되었습니다👍
주석 처리도 좋고, 문제도 깔끔하게 잘 풀어주셨어요!
몇 가지 사소한 코멘트 남겼습니다.
궁금하신 점이 있다면 리뷰어를 호출해주세요!
if(in[i]>0){ | ||
for(int j=0; j<in[i]/2; j++){ | ||
p[left]=p[right]=i+'A'; | ||
left++; right--; | ||
} |
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.
반복 한 번에 앞과 뒤에 동시에 문자를 붙이면서 팰린드롬을 만들어주셨네요! 깔끔합니다👍
} | ||
} | ||
} | ||
if(odd==1) p[str.size()/2]=odd_index+'A'; |
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.
P3
알튜비튜에서는 협업 시 수정을 편리하게 하기 위해서 한 줄이어도 중괄호를 붙이는 것을 권장하고 있습니다!
중괄호까지 붙여주시면 정말 좋을 것 같아요👍
} | ||
|
||
//연산 | ||
ans=in[n-1];//이거 초기화 안해줬더니 79%에서 틀림 |
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.
맞아요! 초기화를 하지 않으면 정답이 나오지 않을 거에요.
왜 그런 결과가 나왔는지 생각해보시는 것도 좋을 것 같아요!
//연산 | ||
ans=in[n-1];//이거 초기화 안해줬더니 79%에서 틀림 | ||
for(int i=n-1; i>=0; i--){ | ||
if(ans<in[i]) ans=in[i]; |
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.
P3
위와 마찬가지로 중괄호 붙여주시면 정말 좋을 것 같습니다!
for(int i=n-1; i>=0; i--){ | ||
if(ans<in[i]) ans=in[i]; | ||
else if(ans>in[i]){ //in[i]와 가장 가까운 배수로 초기화 | ||
if(ans%in[i]){ | ||
ans=((ans/in[i])+1)*in[i];//이렇게 안하고 for문으로 하니까 시간초과 | ||
} | ||
} | ||
} |
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.
최소 속도를 만드는 조건을 파악해서 문제를 잘 풀어주셨네요!👍
if(odd>1) { | ||
cout<<"I'm Sorry Hansoo"; | ||
} |
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.
팰린드롬을 만들 수 없는 조건을 잘 발견해주셨네요!👍
인적사항
학번 : 2271092
이름 : 이한선
과제제출
기존 제출 : 18111, 1213, 17451
추가제출 :