RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00345

Paprika

Unrated 레이팅 미적용
난이도
1s
시간 제한
32MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

\(6^{th}\) round, February \(7^{th}\) 2015
Young Marin is working as an assistant chef in a popular restaurant called Plavi 9 where the daily
offer includes, among other things, stuffed peppers. Every assistant chef knows that the peppers are
stuffed when they are young, so he decided to prepare the meal using only peppers not older than \(X\)
days. Marin will serve all the other peppers fresh, as an appetizer. Luckily, as Croatia entered the
EU, there is a new law enforced. The law states that every pepper has to have its ID card at any
moment. Marin can easily determine the age of a pepper by looking at its ID card.
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.

제약
입력 형식

The first line of input contains two integers \(N\) and \(X\) (1 ⩽N, X ⩽1 000) from the task.
Each of the following \(N\) lines contains two integers \(a\) (1 ⩽\(a\) ⩽1 000) and \(b\) (0 ⩽\(b\) ⩽1) that describe
the peppers in the order which they’re waiting in line to be filled.
The number \(a\) is printed on the ID card of a pepper and represents its age in days, and number \(b\)
represents it’s life purpose (0 if pepper wants to be served fresh or 1 if it wants to be served as a filled
pepper).

출력 형식

The first and only line of output must contain the number of peppers that will have their life purpose
completed.

예제 1
입력
4 5
2 0
3 0
4 0
5 0
5 5
3 1
2 0
13 1
2 0
10 1
6 10
15 1
12 1
8 0
10 1
3 0
1 1
출력
output
output
0
5
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 2014/2015 Contest 6

평가 및 의견

Paprika

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Paprika

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8