SOLVE

LATER

Little Shino and Elo Ratings

Problem

Editorial

Analytics

HackerEarth hired Little Shino to work on the rating system. HackerEarth uses Elo-rating system is used to rank contestants. Suppose two contestants with the current ratings \(r(1)\) and \(r(2)\) compete in a contest. Little Shino have to find their updated rating \(r'(1)\) and \(r'(2)\) after contest?

Little Shino wrote the algorithm to compute the updated rating but he is busy with other things right now so he asked you to write the sql query.

The algorithm is as follows:

The **first step** is to compute the transformed rating for each player or team:

\(R(1) = 10^{r(1)/400}\)

\(R(2) = 10^{r(2)/400}\)

In the **second step** we calculate the expected score for each player:

\(E(1) = \frac {R(1)} {R(1) + R(2)}\)

\(E(2) = \frac {R(2)} {R(1) + R(2)}\)

Now we wait for the match to finish and set the actual score in the third step:

```
if first contestant's rank is less than second contestant's rank
S(1) = 1
else
S(1) = 0
```

```
if second contestant's rank is less than first contestant's rank
S(2) = 1
else
S(2) = 0
```

Now we can put it all together and in a **fourth step** find out the updated Elo-rating for each contestant:

\(r'(1) = r(1) + 32 * (S(1) – E(1))\)

\(r'(2) = r(2) + 32 * (S(2) – E(2))\)

This will give the updated ratings of only 2 contestants. If there are more than 2 contestants, you have to calculate the updated ratings for all possible pairs and the final updated rating of a contestant will be the average of all the updated ratings of that contestant .

**Note**: Output should contain the data in non-increasing order of their updated ratings. The new ratings will be floating point number so round off the answer till the decimal point and print the integer value.

Table : **Ratings**

Field | Type |
---|---|

Name | text |

Rating | int |

Table: **Rank**

Field | Type |
---|---|

Name | int |

Rank | int |

Field | Type |
---|---|

Name | text |

NewRating | text |

**Sample Ratings Table:**

Name | Rating |
---|---|

tourist | 3580 |

Petr | 3481 |

**Sample Rank Table:**

Name | Rank |
---|---|

tourist | 2 |

Petr | 1 |

Name | NewRating | |
---|---|---|

tourist | 3560 | |

Petr | 3501 |

Time Limit:
5 sec(s)
for each input file.

Memory Limit:
256 MB

Source Limit:
1024 KB

Marking Scheme:
Marks are awarded when all the testcases pass.

Allowed Languages:
MySQL,
PostgreSQL,
MSSQL,
Oracle_Db

Initializing Code Editor...

{"b5e0811": "/pagelets/show-submission/sql/little-shino-and-elo-ratings-1/", "a50fccc": "/pagelets/problem-author-tester/sql/little-shino-and-elo-ratings-1/", "9637760": "/pagelets/problems-hint/sql/little-shino-and-elo-ratings-1/", "c58a131": "/pagelets/recommended-problems/sql/little-shino-and-elo-ratings-1/", "5366d17": "/pagelets/suggested-problems/sql/little-shino-and-elo-ratings-1/"}

realtime.hackerearth.com

80

46d55f353dd4c8826ce8c8734c5a22332015aed9

58a29e5cae2309f04b28

/realtime/pusher/auth/