DMOPC '17 Contest 5 P0 - Mimi and Pizza

View as PDF

Submit solution


Points: 3
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Mimi is ordering pizza! She looks at the menu and sees the following options:

Name Price Vegetarian
C $2 No
D $2 Yes
A $5 No
B $5 Yes

Mimi's favourite pizza is type A, her next favourite is type B, then type C, and then type D. She also notes that you can only order 1 type of pizza.

Given her budget in dollars, B, the number of pizzas she wants to buy, P, and whether or not her vegetarian friends want some, determine the most preferred pizza she can buy, or NO PIZZA if she cannot buy P pizzas of any type.

Constraints

0 \le B \le 1\,000
1\le  P \le 1\,000

Input Specification

The first line of input will contain a single integer, B.
The next line of input will contain a single integer, P.
The next line of input will contain either Y if her vegetarian friends are coming, or N otherwise.

Output Specification

The most preferred pizza she can buy, or NO PIZZA if she cannot buy any pizza.

Sample Input

6
2
Y

Sample Output

D

Comments


  • -1
    felixzhang25  commented on March 25, 2018, 10:34 a.m. edited

    what is wrong with my code

    Test case #1: IR (java.util.NoSuchElementException) [0.213s, 28.21 MB] (0/0)