CCO '02 P4 - Duathlon

View as PDF

Submit solution

Points: 10
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: 2002 Stage 2, Day 2, Problem 1

A duathlon is a race that involves running r km and cycling k km. n contestants have entered the race; each contestant has different running and cycling speeds. One of the contestants has bribed the organizers to set r and k so that he can win by the maximum margin. You are to determine if this is possible and, if so, give r and k.

Input Specification

The first line of input contains an integer t, the total distance of the race, in km. That is, r + k = t. The next line contains an integer n, the number of competitors. For each contestant, a line follows with two real numbers giving the running and cycling speed for that contestant. The last line of input gives the running and cycling speed of the contestant who has bribed the organizers. You may assume t does not exceed 100 km and n does not exceed 20.

Output Specification

If it is possible to fix the race as describe above, print a message giving r and k, and the amount by which the cheater will win the race, accurate to two decimal places as in the sample below. If it is not possible, print The cheater cannot win.

Sample Input 1

100
3
10.0 40.0
20.0 30.0
15.0 35.0

Sample Output 1

The cheater can win by 612 seconds with r = 14.29km and k = 85.71km.

Sample Input 2

100
3
10.0 40.0
20.0 30.0
15.0 25.0

Sample Output 2

The cheater cannot win.

Comments

There are no comments at the moment.