[요약] n개의 고추가 각각 삶의 목표를 가지고 있다.
삶의 목표는 0과 1로 입력된다.
각각의 고추는 자신의 다음에 있는 고추와 번호를 바꾸었을때 둘 다 삶의 목표를 이룰 수 있는경우 번호를 바꾸기로 한것이다!! 번호 바꾸기가 모두 끝난 뒤 자신의 삶의 목표를 달성할 고추의 수를 구하는 것이 문제이다.
It is less known that peppers have, besides official documents, their own life purposes and ambitions. More precisely, every pepper knows from an early age whether they want to be served as a fresh or stuffed pepper when they grow up. Bearing that in mind, you are aware of the problems N peppers are facing while waiting in line to be filled. The life purpose of some peppers is to be a part of the dish, but they are too old, and some peppers want to be served fresh, but will be filled.
Because the peppers aren’t aware of Marin’s number X, they have decided to rectify the injustice using the following strategy. The first pepper tries to switch its ID card with second pepper, then the second pepper tries to switch its ID card with the third pepper and so on until the end of the line. Two peppers will switch their ID cards if the pepper that has a larger number on the ID card it’s currently holding wants to become a filled pepper, and the one with the smaller number doesn’t. The peppers will not switch ID cards if they have equal numbers on them.
Your task is to determine the number of peppers that will have their life purpose completed.
입력 4 5 2 0 3 0 4 0 5 0 출력 0 입력 5 5 3 1 2 0 13 1 2 0 10 1 출력 5 입력 6 10 15 1 12 1 8 0 10 1 3 0 1 1 출력 4 Clarification of the first example: All peppers are young enough, but not a single one of them wants to be stuffed. Clarification of the second example: Every two adjacent peppers switched their ID cards.
출처:coci 2013-2014 contest6 1/6 요약: baji072