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
;
- CPU speed (in megahertz), denoted as
;
- disk drive space (in gigabytes), denoted as
.
You perform some analysis and determine that the most preferred machine is the machine that has the largest value of the formula .
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 (
). Each of the remaining
lines of input will contain a computer specification. A computer specification is of the form:
- computer name (a string of less than
characters)
- the RAM available (an integer
with
)
- the CPU speed (an integer
with
)
- the disk drive space (an integer
with
)
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 . Computer
DEF
has a computed value of . Computer
GHI
has a computed value of . Computer
JKL
has a computed value of . Therefore, computer
JKL
is the most preferred, followed by computer DEF
.
Comments
Since the original data were weak,
new test cases were added that force the output constraints.
Hello, why is my code getting so many answers? I can't figure it out. https://dmoj.ca/submission/4376184 Thank you!
Consider if n = 0.
Does anyone know why I'm getting test case 5 and 6 wrong?
You should probably reread the question.
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?
Thank you so much, I really misread the question.
This comment is hidden due to too much negative feedback. Show it anyway.
When you forget the problem you're doing is from 2010
This comment is hidden due to too much negative feedback. Show it anyway.
Consider the case
Does case matter for lexicographically? Are "ABC" and "abc" the same?
what if all of the scores are the same??? do we still lexicographically print it out???
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.
Two of the test cases are the same; 5 and 6.
This comment is hidden due to too much negative feedback. Show it anyway.
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.
Ok. Thanks. Will keep that in mind.
This comment is hidden due to too much negative feedback. Show it anyway.
You don't have to print anything if