CCC '05 J1 - The Cell Sell

View as PDF

Submit solution

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

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
Canadian Computing Competition: 2005 Stage 1, Junior #1

Moe Bull has a cell phone and after a month of use is trying to decide which price plan is the best for his usage pattern. He has two options, each plan has different costs for daytime minutes, evening minutes and weekend minutes.

Plan Costs
daytime evening weekend
A 100 free minutes then 25 cents per minute 15 cents per minute 20 cents per minute
B 250 free minutes then 45 cents per minute 35 cents per minute 25 cents per minute

Write a program that will input the number of each type of minutes and output the cheapest plan for this usage pattern, using the format shown below. The input will be in the order of daytime minutes, evening minutes and weekend minutes. In the case that the two plans are the same price, output both plans.

Sample Input 1

251
10
60

Sample Output 1

Plan A costs 51.25
Plan B costs 18.95
Plan B is cheapest.

Sample Input 2

162
61
66

Sample Output 2

Plan A costs 37.85
Plan B costs 37.85
Plan A and B are the same price.

CCC problem statements in large part from the PEG OJ


Comments


  • 0
    DavidE  commented on Oct. 6, 2020, 9:18 p.m.

    The problem I had was that I wasn't outputting only two decimal places, one of the tests is to input all three variables as 0 and if you don't output 0.00 for the first two outputs, you won't even get a single mark, If you think this is the problem for you and you are using Java use this link,

    https://www.java67.com/2014/06/how-to-format-float-or-double-number-java-example.html#:~:text=format(%22%25.,float%20data%20type%20in%20Java.

    if you aren't using java search up number formats for two decimal places for your language, this simple fix got me from 0 points from all tests to 100%.


  • 2
    Evang  commented on March 22, 2020, 9:10 p.m.

    Remember: for each of the plans, it's some_value cents/minute. The output prices for each of the plans should be in dollars :)


  • -2
    Anoojen643_VP  commented on Feb. 26, 2020, 10:56 p.m.

    wth my program runs perfectly but i counts it as wrong what is the word for word output? also can anyone tell me the test code so i can try this out for my self


  • 2
    wleung_bvg  commented on Dec. 8, 2019, 8:06 a.m.

    Pleas refrain from spamming the submit button when the judges are broken. If it got Internal Error 3 minutes ago, and 2 minutes ago, and 1 minute ago, you might want to consider waiting a while before resubmitting.


  • -1
    WEAVER  commented on May 13, 2019, 6:49 p.m.

    Im new to programming, Can someone help I do this problem


  • 10
    saysuhayl  commented on Oct. 14, 2018, 12:31 a.m.

    Spent 20 mins debugging because the output is worded "Plan B is cheapest." vs "Plan B is the cheapest." which is proper grammar.


    • -10
      Arihan10  commented on Feb. 23, 2019, 7:19 p.m.

      This comment is hidden due to too much negative feedback. Click here to view it.


    • 4
      Summertony717  commented on Feb. 23, 2019, 3:06 p.m.

      Only 20 min? Good job, that would have taken me hours.


  • -2
    Epic1Online  commented on Oct. 30, 2017, 5:11 p.m. edit 2

    Are compile errors due to bad code? Because my code works on my laptop but I get a compile error when submitting. The same thing happened for another problem but I resubmitted and it worked but that's not fixing the error here.

    EDIT: I fixed it by using Math.round() instead of DecimalFormat, but I don't see why DecimalFormat shouldn't work (Java 8)


    • 6
      injust  commented on Oct. 30, 2017, 6:41 p.m.

      You may want to import java.text.DecimalFormat.


  • 1
    Selena_Liu  commented on July 12, 2017, 12:51 a.m.

    I don't get why my first case is wrong. They are the same price, aren't they?


    • 7
      injust  commented on July 12, 2017, 3:35 a.m.

      Your program prints Plan A and Plan B are the same price. when the plans cost the same amount.


  • -9
    lolzballs  commented on March 18, 2015, 1:16 p.m.

    This comment is hidden due to too much negative feedback. Click here to view it.


    • 1
      HyperNeutrino  commented on Feb. 23, 2019, 5:51 p.m.

      "Plan A is cheap"

      "Plan A is cheaper"

      ...

      Both are correct; cheapest is an adjective but it's a superlative so you can also stick a definitive article (i.e. "the") in front of it and treat is as though it were a noun.


    • 1
      FatalEagle  commented on March 18, 2015, 1:17 p.m.

      How correct the grammar is doesn't matter; it's simply the output specifications.


  • -2
    Hunterdrago1  commented on Oct. 18, 2014, 6:31 p.m.

    Plan A costs 37.85 Plan B costs 37.849999999999994 Plan B is cheapest.


    • -6
      FatalEagle  commented on Nov. 1, 2014, 12:17 a.m.

      This comment is hidden due to too much negative feedback. Click here to view it.


      • -5
        Miss  commented on Nov. 19, 2014, 2:05 p.m.

        This comment is hidden due to too much negative feedback. Click here to view it.


        • -4
          FatalEagle  commented on Nov. 19, 2014, 6:47 p.m.

          The answer must be to exactly 2 decimal places. The constraints are such that the correct answer will not have any nonzero digits after and including the third decimal place.


  • 0
    Zhenpai  commented on Oct. 7, 2014, 9:41 p.m.

    I think there's a problem with your problem, and I have a problem with that.


    • 7
      quantum  commented on Oct. 7, 2014, 10:22 p.m.

      There is no problem with this problem.