Logo
(追記) (追記ここまで)

15220번 - Hay Bales 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB48111043.478%

문제

Peter has lined up hay bales. Some hay bales contain parasites and he wants to move the infected hay bales to the back of the sequence, to minimize the chance that the parasites spread. To sort the haybales, he repeatedly takes out any three consecutive hay bales and puts them back in sorted order. Your task is to calculate the minimum number of operations Peter has to execute to sort the sequence.

입력

The input contains a single string s (3 ≤ |s| ≤ 500), the sequence of hay bales. Each character of s is either ‘C’ (for a clean hay bale) or ‘P’ (for an infected one).

출력

The output must contain one integer, the minimum number of steps Peter has to execute.

제한

예제 입력 1

CPCC

예제 출력 1

1

예제 입력 2

PPPPCCCC

예제 출력 2

8

예제 입력 3

CCCCPPPP

예제 출력 3

0

힌트

출처

Contest > KTH Challenge > KTH Challenge 2016 F번

  • 문제를 만든 사람: Jan Elffers
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /