ECOO '17 R1 P1 - Munch 'n' Brunch

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 30.0s
Memory limit: 64M

Problem type
Author: Andrew Seidel

Student council is looking to organize a school brunch, where the proceeds will be put towards a year-end trip for the graduating class. The council members decide that the price depends on how many years you have been at the school. For someone who has been at the school for one year (Y1), the price will be $12, for someone who has been at the school for two years (Y2), the price will be $10, the three-year (Y3) price will be $7, and the price for someone who has been there all four years (Y4) will be $5.

Out of all the proceeds, 50% can be saved towards the year-end trip, as the other 50% is spent on the various costs to run the brunch. Given the following input data, calculate whether or not the council will need to raise additional funds.

Input Specification

The input contains 10 trips, at 3 lines of data per trip.

  • For each of the trips, the first line will show the cost of the trip as an integer ($50 to $50000).
  • The next line contains four floating point numbers Y1, Y2, Y3, Y4 (0Y1,Y2,Y3,Y41 and Y1+Y2+Y3+Y4=1) representing the percentages of the total number of students from years 1 through 4 respectively.
  • The third line contains a single number N, which contains the total number of students attending the brunch (4N2000).

Note: You cannot have less than a whole person (e.g., 1.8 people is the same as 1 person). Any missing or extra people should be removed from or added to the group with the highest percentage of attendees. There will always be exactly one group with the highest percentage of attendees.

Output Specification

Output YES if the student council needs to find other funding, and NO if the council has raised sufficient funds.

Sample Input

Copy
4000
0.5 0.2 0.1 0.2
400
6000
0.1 0.1 0.45 0.35
2000

Sample Output

Copy
YES
NO

Note: Only 2 cases are shown in this sample.

Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org


Comments


  • 0
    Joe_C137  commented 20 days ago

    I ran my code through many tests with randomly generated numbers and it consistently gives the correct answer, but the judge will not accept it here. I even changed my "<=" to a "<", as Nathan did above, but it did not work (if you've completed this challenge, you know there are two values you must compare at the end in order to yield a result). I don't see where this is going wrong, and I am annoyed because DMOJ gives no feedback. It's certainly not a bug, as the program works just as it should. I also did make sure that my Output prints 'NO' if sufficient funds are raised (it's easy to mistakenly write 'YES' thinking this means 'Yes, they have raised enough funds' but this is incorrect based on the wording of the challenge).

    Any help will be greatly appreciated, thank you.


    • 0
      Joe_C137  commented 20 days ago

      Never mind, I see that I overlooked a crucial piece of information: This program must process data for ten trips, not just a single trip as I had done. It's likely that once I adjust for that it will work fine.


  • 0
    nathanxrichards  commented on Nov. 7, 2024, 2:19 a.m.

    As an improvement to this problem, I want to point out that the one can write a script that takes the Sample Input and provides the Sample Output and still miss a couple of important details that cause the submitted solution to fail.

    I find one entirely my fault; I didn't read the instructions clearly and left out a step.

    On the other, my script worked for all but the final test, and I disagree with this assessment. I tracked down the part of the code that lead to it failing, and resubmitted for full points. That said, I feel that my original code with a"<=" should have not failed, and that the working code with a "<" should fail.