회원가입
로그인
Toggle navigation
문제
문제
전체 문제
문제 출처
단계별로 풀어보기
알고리즘 분류
추가된 문제
문제 순위
문제
푼 사람이 한 명인 문제
아무도 못 푼 문제
최근 제출된 문제
최근 풀린 문제
랜덤
출처
ICPC
Olympiad
한국정보올림피아드
한국정보올림피아드시․도지역본선
전국 대학생 프로그래밍 대회 동아리 연합
대학교 대회
카카오 코드 페스티벌
Coder's High
ICPC
Regionals
World Finals
Korea Regional
Africa and the Middle East Regionals
Europe Regionals
Latin America Regionals
North America Regionals
South Pacific Regionals
문제집
대회
2
채점 현황
랭킹
게시판
그룹
더 보기
재채점 기록
블로그
강의
실험실
도움말
BOJ Stack
BOJ Book
전체
공지
자유
질문
오타/오역/요청
게시판 공지
홍보
업데이트
solved.ac
글쓰기
질문 도움말
자주묻는 질문
반례 또는 조언 부탁드립니다.
2621번 - 카드게임
zhsks528
3년 전
0
테스트케이스는 맞다고 나오는데 결과적으로는 틀렸다고나옵니다.
반례가 있거나 어느 부분에서 틀렸는지 조언 부탁드립니다
from collections import Counter def same_color(colors): if len(set(colors)) == 1: return True return False def continue_numbers(numbers): numbers.sort() is_true = False for i in range(len(numbers)-1): if numbers[i] + 1 == numbers[i+1]: is_true = True else: is_true = False break return is_true colors = [] numbers = [] result = 0 for i in range(5): color, number = input().split() colors.append(color) numbers.append(int(number)) is_same = same_color(colors) is_continue = continue_numbers(numbers) if is_same == True and is_continue == True: result = numbers[0] + 900 elif is_same == True and is_continue == False: result = max(numbers) + 600 elif is_same == False and is_continue == True: result = max(numbers) + 500 else: count_num = sorted([(key, value) for key, value in Counter( numbers).items()], key=lambda x: x[1], reverse=True) for idx in range(len(count_num)): if len(count_num) == 2: if count_num[0][1] == 4: result = count_num[0][0] + 800 else: result = count_num[0][0] * 10 + count_num[1][0] + 700 elif len(count_num) == 3: if count_num[0][1] == 2 and count_num[1][1] == 2: result = max(count_num[0][0], count_num[1][0]) * \ 10 + min(count_num[0][0], count_num[1][0]) + 300 elif count_num[0][1] == 3: result = count_num[0][0] + 500 elif len(count_num) == 4: result = count_num[0][0] + 200 else: result = max(count_num[idx]) + 100 print(result)
댓글을 작성하려면
로그인
해야 합니다.
zhsks528 3년 전
테스트케이스는 맞다고 나오는데 결과적으로는 틀렸다고나옵니다.
반례가 있거나 어느 부분에서 틀렸는지 조언 부탁드립니다