CCC '10 S1 - Computer Purchase

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 256M

Problem type
Canadian Computing Competition: 2010 Stage 1, Senior #1

In order to increase your performance on the ABC (Another Buying Contest), you decide that you need a new computer. When determining which computer to buy, you narrow your search categories to:

  • RAM (in gigabytes), denoted as R;
  • CPU speed (in megahertz), denoted as S;
  • disk drive space (in gigabytes), denoted as D.

You perform some analysis and determine that the most preferred machine is the machine that has the largest value of the formula 2R + 3S + D.

Your task is to read a given list of computers and output the top two computers in order of preference, from highest preference to lowest preference.

Input Specification

The first line of input will be an integer n (0 \le n \le 10\,000). Each of the remaining n lines of input will contain a computer specification. A computer specification is of the form:

  • computer name (a string of less than 20 characters)
  • the RAM available (an integer R with 1 \le R \le 128)
  • the CPU speed (an integer S with 1 \le S \le 4000)
  • the disk drive space (an integer D with 1 \le D \le 3000)

There is one space between the name, RAM, CPU speed and disk drive space on each line.

Output Specification

The output is the name of the top two preferred computers, one name per line, sorted in decreasing order of preference. If there is a tie in the rankings, pick the computer(s) whose name(s) are lexicographically smallest (i.e., Apple is smaller than Dell). If there is only one computer, output that computer on one line (i.e., do not print it twice).

Sample Input

4
ABC 13 22 1
DEF 10 20 30
GHI 11 2 2
JKL 20 20 20

Output for Sample Input

JKL
DEF

Explanation of Output for Sample Input

Computer ABC has a computed value of 93. Computer DEF has a computed value of 110. Computer GHI has a computed value of 30. Computer JKL has a computed value of 120. Therefore, computer JKL is the most preferred, followed by computer DEF.


Comments


  • 0
    IAMW  commented on March 21, 2024, 4:10 a.m.

    Why is my code only failing the last test case someone help!!!!!


  • 4
    maxcruickshanks  commented on May 6, 2022, 12:15 a.m.

    Since the original data were weak, 2 new test cases were added that force the output constraints.


  • 0
    X_star12321  commented on Feb. 26, 2022, 12:21 a.m.

    Hello, why is my code getting so many answers? I can't figure it out. https://dmoj.ca/submission/4376184 Thank you!


  • 5
    Brian_Li23  commented on Jan. 28, 2021, 10:03 p.m.

    For whoever knows how to code in python and finished this question, could anyone check my submission and tell me why I keep getting only test case #1 wrong?


    • 8
      Kirito  commented on Jan. 28, 2021, 10:09 p.m.

      If there is a tie in the rankings, pick the computer(s) whose name(s) are lexicographically smallest (i.e., Apple is smaller than Dell).


      • 1
        Brian_Li23  commented on Jan. 28, 2021, 10:38 p.m. edit 2

        Thank you so much, I really misread the question.


  • -13
    potato_nuggetz  commented on July 5, 2020, 7:42 p.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


    • 14
      noYou  commented on July 10, 2020, 4:06 p.m.

      When you forget the problem you're doing is from 2010


  • -9
    Orion222  commented on May 15, 2020, 4:31 p.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


    • 4
      Kirito  commented on May 16, 2020, 9:17 p.m.

      Consider the case

      1
      ABC 13 22 1

  • -7
    kevinlu1248  commented on Feb. 3, 2020, 12:47 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -5
    Charles232  commented on Jan. 22, 2019, 2:49 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


    • 4
      Relativity  commented on Jan. 22, 2019, 2:43 p.m.

      The output is the name of the top two preferred computers, one name per line, sorted in decreasing order of preference. If there is a tie in the rankings, pick the computer(s) whose name(s) are lexicographically smallest.


  • 5
    ThatGuyOnTheStreet  commented on Nov. 11, 2018, 8:57 p.m.

    Two of the test cases are the same; 5 and 6.


    • -23
      Arihan10  commented on Jan. 22, 2019, 6:10 p.m. edited

      This comment is hidden due to too much negative feedback. Show it anyway.


      • 37
        Robloxian  commented on Jan. 22, 2019, 10:13 p.m.

        Before posting, ask yourself:

        Will someone reading my comment a year from now find it useful? If not, then you probably shouldn't post it. Will I regret posting this comment in five minutes? If so, you shouldn't post it. Listen to yourself. Is my comment meaningful? Comments like "uw0tm8" are unwelcome. Is the thread I'm commenting on longer than the problem itself? If it is, do you really have something of value to add? This is not to say that jokes or witty comments are unwelcome. They're fine. If you think your comment relates to the problem and is funny for the majority of people who will read it (i.e. not an inside joke only you and your friend will understand — we're not Facebook), then by all means post ahead! If you can brighten someone's day while remaining even remotely on topic, that's great.

        And these are just guidelines. If you feel really justified in posting something, use your judgement.


        • 14
          Arihan10  commented on Jan. 23, 2019, 1:39 a.m.

          Ok. Thanks. Will keep that in mind.


  • -10
    bobhob314  commented on Dec. 25, 2014, 2:34 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


    • 8
      FatalEagle  commented on Dec. 25, 2014, 2:40 a.m.

      You don't have to print anything if n = 0