Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

NUMBERS - Editorial

$
0
0

Problem Link:

Practice
Contest

Difficulty:

CakeWalk

Pre-requisites:

Sorting

Explanation:

Sub tasks 1, 2, 3:

The constraints in these subtasks are designed in such a way that it is possible just to check every single person in O(N) time. This way, the solution will look like: for every player check the fact that any other player's number is not equal to the number of this player and if it is so just check that this person's number is minimal.

All the sub tasks:

If you sort all the players according to the numbers that they have said (obviously, in order from the smallest to the largest), it's easy to see that in order to check the uniqueness of any player's number, it's sufficient to look at the numbers of his left and right neighbor in this sorted list. This way, we obtain O(N) solution after sorting and O(NlogN) solution for a single test case.

Setter's solution:

Can be found here

Tester's solution:

Can be found here


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>