KayaksProblem code: H2 |
All submissions for this problem are available.
Suppose we have an even number of people going on an excursion, and we would like to fit them into two-seated kayaks. All kayaks are identical, weighing 20kg each. Each person is described by two parameters, their strength and weight. The speed of a kayak can be calculated as the sum of strengths of both persons sitting in it, divided by the total weight of the loaded kayak (i.e., the weight of the kayak plus the weight of both persons). We would like to choose the allocation of people to kayaks so as to maximize the speed at which the whole whole group can travel, assuming that the group travels at the speed of the slowest kayak in it.
Input
First, 2 ≤ n ≤ 105, the number of people (n will always be even). Then, n pairs of integers follow, each pair describing one person: first, 50≤w≤100, the weight of the person (in kilograms), then 50≤p≤100, the strength of the person.
Output
Output one number: the maximum speed of the group which can be achieved by optimally choosing places for each person. The answer should be accurate up to 6 digits after the decimal point.
Example
Input: 4 50 50 50 60 70 100 100 60 Output: 0.842105
| Date: | 2009-09-15 |
| Time limit: | 2s |
| Source limit: | 50000 |
| Languages: | C C99 strict C++ PAS gpc PAS fpc JAVA NICE JAR C# C#2 NEM ST ASM D FORT ADA BASH PERL PYTH RUBY LUA ICON PIKE PHP SCM guile SCM qobi LISP sbcl LISP clisp SCALA HASK CAML CLPS PRLG WSPC BF ICK TEXT |
Comments

Fetching successful submissions 
If the output is 0.2 is it
If the output is 0.2 is it required to print 0.100000 all six decimal places padded with zeros?
If the output is 0.2 is it
If the output is 0.2 is it required to print 0.200000 all six decimal places padded with zeros?
No.
No.
Are C++ submissions compiled
Are C++ submissions compiled with -O2?
@Tomaz I believe they are.
@Tomaz I believe they are.
any body know the logic there
total weight of the loaded
total weight of the loaded kayak i.e., the weight of the kayak plus the weight of both persons. What is the weight of kayak?
... All kayaks are identical,
... All kayaks are identical, weighing 20kg each. ...
My program runs without any
:D... My mistake. Sorry!
My mistake. Sorry!
hello guys, I'm kind of new
hello guys, I'm kind of new here ,
can you tell me how to view the compilation error results?
error occured at codechef.
thanks.
can any body explain me this
@Rajul : The problem
@Rajul : The problem statement says "....maximize the speed at which the whole whole group can travel, assuming that the group travels at the speed of the slowest kayak in it...."
For the given problem, there are 3 possible pairings viz.
(1,2) ; (3,4).... speed1 = min (160/120, 160/190)
(1,3) ; (2,4).... speed2 = min (150/140, 120/170)
(1,4) ; (2,3).... speed3 = min (110/170, 160/140)
Ans = max(speed1, speed2, speed3) = 160/190 = 0.842105
THANKS SHISHIR MITTAL
THANKS SHISHIR MITTAL
Do we have to round up the
Do we have to round up the 6th digit after decimal ??for eg if ans is 0.1234567 than we have to print 0.123456 or 0.123457
I don't have a gcc 4.0.0-8
@anjani: Use Dev CPP on
@anjani: Use Dev CPP on windows. That comes with gcc compiler.
@anjani you can take a look
@anjani you can take a look at www.codechef.com/wiki for more information on where you can get the compilers from.
i'm getting run time
i'm getting run time error....
but it doesn,t show this in dev-cpp
what should i do?
It probably doesn't show up
It probably doesn't show up in dev-cpp because you haven't tested it on large inputs.