2810. 컵홀더

멍진이·2021년 6월 16일
0

백준 문제풀기

목록 보기
12/36

문제 링크

2810. 컵홀더

문제 코드

man = int(input())

seat_list = input()

couple_count = 0
for seat in seat_list:
    if seat == 'L':
        couple_count+=1

if couple_count  == 0:
    print(man)
else:
    print(man-(couple_count-2)//2)

문제 풀이

  • 규칙을 발견하다보니 전체 사람수에서 copule의 개수 -2 //2 만큼 빼주면 된다는 것을 확인
  • couple_count 가 0 일 경우 copule의 개수 -2 //2를 하면 -1이 되므로 커플석이 없을때는 그냥 사람수만큼 출력
profile
개발하는 멍멍이

0개의 댓글