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

10280번 - Pizza voting 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 256 MB47921114542.647%

문제

You are training for a programming contest with your team members Alice and Bob. After some hours of hard training you want to have a break and eat pizza. You decided to order a big pizza for all three of you. But you have to choose the kind of pizza you want to eat.

You know your favorite kind. But Alice and Bob have other constraints: Alice is on a diet so she wants a pizza with less calories as possible. Bob is just mean to Alice so he votes for as much calories as possible.

You decide to vote on which kind of pizza you order. As voting for one pizza wouldn’t lead anywhere, you decide to use a veto voting. So everyone of you veto on pizza in a round robin manner. First Alice vetos one pizza, then Bob vetos one, at last you are allowed to veto. Then Alice has the next veto again, then Bob etc. until only one pizza is left.

Reminder: Alice will always veto the pizza with the most calories. Bob vetos always the pizza with least calories. You try to be clever in such a way that your favorite pizza is the remaining pizza.

입력

The input starts with the number of pizzas n (1 ≤ n ≤ 100 000) and the index of your favorite pizza p (1 ≤ p ≤ n) (1-indexed). Then follow the description of the n pizzas, each given in one line. The description consists of one integer c (0 ≤ c ≤ 1 000 000) giving the calories followed by a single word w giving the name of the pizza (up to 100 characters). The pizzas are ordered from low calories to high calories and the number of calories is unique for every pizza.

출력

Output one line. “YES” if you can vote in a way, such that your pizza will be selected. “NO” if you are not able to influence the vote in a way that your pizza will be selected.

제한

예제 입력 1

5 2
500 Margherita
600 Salami
700 Hawai
800 Speciale
900 Doener

예제 출력 1

YES

예제 입력 2

5 4
500 Margherita
600 Salami
700 Hawai
800 Speciale
900 Doener

예제 출력 2

NO

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > German Collegiate Programming Contest > GCPC 2014 K번

  • 데이터를 추가한 사람: sait2000
(追記) (追記ここまで)

출처

대학교 대회

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

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