Statement

## Goal

During motorcycle competitions, the speeds achieved are incredible. But this speed is often the cause of accidents, especially in bends. Indeed, when entering a bend, the motorcycle undergoes the centrifugal force that drives the motorcycle out of the bend. To combat this, riders use a technique called "centripetal tilt" which consists in tilting the bike towards the inside of the bend to compensate for this force. This technique reaches its limits when the speed is too high, which can lead to slippages that lead to falls. Hence the importance of controlling your speed ;)

The purpose of this puzzle is to define the maximum constant speed that your bike must have to pass all the bends of the circuit without stalling and while being the first in the competition. In addition, your job will be to develop the ranking for this competition.

The ranking of this competition is done in this way:
V=Speed
- If Va>Vb>Vc then "a" first, "b" second, "c" third.
- If Va>Vb>Vc and "a" falls then "b" first, "c" second, "a" third
- If Va>Vb>Vc and "b" falls at bend 2 and "a" at bend 5 then "c" first, "a" second, "b" third
- If Va>Vb>Vc and "b" falls at the same bend as "a" then "c" first, "a" second, "b" third
In the final ranking, you are also counted and represented by the letter "y" (as the goal of this puzzle is that you are the optimal speed you will always be in the first position).

Finally, to know the angle for vertical relation you will need this:
tan(θ) = v² / (r × g)
v = speed (m/s) / r = radius of the bend (m) / g = 9.81 (m/s²) / θ = angle with respect to the vertical (degrees)
A motorcycle will stall if the angle to the ground is < 30 degrees.
Input
First line: Number n of motorcycles (other than yours) participating in the competition.
Second line: Number v of curves in the circuit.
Next n lines: The constant speed of each motorcycle (The first speed of the list given by the loop is that of competitor a, the second that of competitor b...) (m/s).
Next v lines: The radius of each curve of the circuit (m).
Output
First line: The maximum constant speed to avoid stalling in the circuit.
Last n+1 lines: The ranking of the competition.
Constraints
0 < n, v < 13
0 < speed < 70
0 < r < 200
The output angles are always integers
Example
Input
8
2
56
6
2
23
9
25
41
15
40
30
Output
22
y
h
e
b
c
f
d
a
g

Tags
Physics

Difficulty
Easy

Test cases
Example Test
Input
8 2 56 6 2 23 9 25 41 15 40 30
Output
22 y h e b c f d a g

Example Validator
Input
11 11 52 21 14 31 42 15 62 56 18 6 43 100 90 80 70 60 50 40 30 20 10 1
Output
4 y j i f c b d g h a k e

Stalling Test
Input
11 3 20 15 48 13 53 33 3 37 22 42 17 160 80 20
Output
18 y k b d g f i a c j h e

Stalling Validator
Input
10 1 15 45 30 25 3 8 19 65 58 55 150
Output
50 y b c d g a f e h i j

Real case Test
Input
11 7 25 48 35 41 26 15 32 37 9 46 6 130 120 110 100 90 80 50
Output
29 y e a f i k c g h d j b

Real case Validator
Input
7 2 15 45 30 25 3 8 19 52 25
Output
20 y g a f e d b c

Just a little one Test
Input
11 1 25 17 35 11 2 15 22 56 8 46 6 5
Output
9 y i k e h j c a g b f d

Just a little one Validator
Input
3 1 15 45 30 50
Output
29 y a b c

Duel Test
Input
1 1 32 60
Output
31 y a

Duel Validator
Input
1 1 2 60
Output
31 y a

Solution language

Solution

Stub generator input
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
Online Participants