## TSOC '15 Contest 2 #5 - Bebiliths

View as PDF

Points: 7 (partial)
Time limit: 0.6s
Java 0.75s
PyPy 2 1.0s
PyPy 3 1.0s
Memory limit: 100M
Java 50M

Authors:
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

Regroup! Regroup!

The caves have been completely traversed, and Mr. Benum has been located! However, the quest is not over. Swarms of bebiliths, or spider-monsters the size of elephants, are swiftly decimating the ex-convicts! It is up to Max to command the remaining ex-convicts so that they can exterminate the bebilith army. But first, Max has to ensure that the ex-convicts will stay alive!

There are bebiliths in pursuit of one of the groups of ex-convicts. Each bebilith has a speed , a venom-spitting distance and a claw sharpness (where the bebilith with the sharpest claw has the highest value of ). Meanwhile, the ex-convicts are running at a uniform speed .

If two bebiliths have the same speed and are faster or at pace with the ex-convicts, the bebilith with the sharpest claws is more dangerous. However, if two bebiliths have the same speed but are slower than the ex-convicts, the bebilith that spits venom the farthest is more dangerous. Otherwise, if two bebiliths have different speeds, the faster one is more dangerous. Max numbers each bebilith for from to . If there is a tie between two bebiliths in terms of how dangerous they are, the one that is numbered the lowest is considered more dangerous. Help Max determine what number represents the most dangerous bebilith times!

#### Input Specification

First line:

Second line:

Next lines: Three space-separated integers on each line. Line represents the characteristics of the bebilith.

Line :

Next lines: A single integer on each line, indicating that the most dangerous bebilith's number should be reported back to Max.

#### Output Specification

lines of the most dangerous bebilith's number as queried.

#### Sample Input

5
4
7 29 61
7 42 59
4 1 441221001
3 7 9996999
4
1
2
3
4

#### Sample Output

1
2
3
4

#### Explanation

Bebiliths and have the same speed, and both are the fastest. Their speed is greater than Max's speed. Bebilith has sharper claws, so it is the most dangerous, while bebilith is the most dangerous. Bebilith is faster than bebilith , so they are the and most dangerous, respectively.

## Comments

• commented on April 21, 2015, 8:14 p.m.

I had a really great time reading through your code!

• commented on April 21, 2015, 10:41 p.m. edited

return true;

• commented on April 21, 2015, 10:05 a.m.

For C/C++ submissions, you may get IR error because of the 2M memory limit. Question makers may hate other programming languages except python and java :P