-
Notifications
You must be signed in to change notification settings - Fork 5
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
[여름방학 3주차] - 허원일 #61
Open
wonza-hub
wants to merge
3
commits into
CBNU-Nnet:main
Choose a base branch
from
wonza-hub:3주차/허원일
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
The head ref may contain hidden characters: "3\uC8FC\uCC28/\uD5C8\uC6D0\uC77C"
Open
[여름방학 3주차] - 허원일 #61
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
n = int(input()) | ||
for _ in range(n): | ||
N, M = map(int, input().split()) | ||
if N < 12 or M < 4: # L4 자리가 존재할 수 없는 경우 | ||
print(-1) | ||
else: | ||
print(M*11 + 4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
N = int(input()) | ||
line = [] # 줄 정보 | ||
long_seq = [] | ||
|
||
# 최대길이를 계산하는 함수 | ||
def max_seq_cap(line): | ||
max_count = 1 | ||
count = 1 | ||
for i in range(0, len(line)-1): | ||
if line[i] == line[i+1]: # 연속된 두 원소가 같으면 count 증가 | ||
count += 1 | ||
else: # 다르면 max_count 초기화 | ||
max_count = max(count, max_count) | ||
count = 1 # count 초기화 | ||
return max(count, max_count) # 예외처리 - new_line이 한 용량으로만 이루어진 경우 | ||
|
||
for _ in range(N): | ||
cap = int(input()) | ||
line.append(cap) | ||
set = set(line) # 줄에 있는 구매자들이 원하는 용량종류를 담는 집합 | ||
|
||
for element in set: | ||
new_line = line.copy() # line을 복사해 new_line을 생성 | ||
while element in new_line: # 특정 용량을 원하는 사람을 모두 뺌 | ||
new_line.remove(element) | ||
long_seq.append(max_seq_cap(new_line)) | ||
|
||
print(max(long_seq)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
def solution(record): | ||
answer = [] | ||
uid_arch = {} # 유저아이디 : 닉네임 을 저장하는 딕셔너리 | ||
|
||
# 반복문을 돌며 기록 처리 | ||
for rec in record: | ||
rec_splited = rec.split() | ||
if (rec_splited[0] == 'Enter') or (rec_splited[0] =='Change'): | ||
uid_arch[rec_splited[1]] = rec_splited[2] | ||
|
||
# 반복문을 돌며 처리된 기록을 바탕으로 메시지 저장 | ||
for rec in record: | ||
rec_splited = rec.split() | ||
if rec_splited[0] == 'Enter': | ||
answer.append(f"{uid_arch[rec_splited[1]]}님이 들어왔습니다.") | ||
elif rec_splited[0] == 'Leave': | ||
answer.append(f"{uid_arch[rec_splited[1]]}님이 나갔습니다.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 와.. split을 이용하여 깔끔하게 잘 푸셨네요 ㄷㄷㄷ 코드 잘 봤습니다 감사합니다! |
||
|
||
return answer |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
리스트를 복사 -> 특정 용량 제거(set의 element) -> 최대 길이 계산(max_seq_cap 함수 호출)
수순으로 진행되는 건가보네요 ㅎㅎ
직관적으로 굉장히 잘 짜신거 같습니다!
추가적으로
new_line -> 특정 용량 제거(set의 element)
과정을 없애서 풀 수도 있으니 시간 되시면 한번 도전해보시는 걸 추천드립니다 ㅎㅎ