niveditavb05's blog

By niveditavb05, history, 23 months ago, In English

Dragon Race Problem | Codehive Contest | 4th Problem

PROBLEM LINK : CodeHive/Dragon Race

Author & Tester : Vedant Patil

Editorialist : Nivedita Birajdar

DIFFICULTY :

CAKEWALK...

PREREQUISITES:

Basic Arithmatics

PROBLEM :

Jake is a very competitive guy. The flying speed of Toruk i.e.Dragon of Jake is exactly 100 kmph i.e. kilometers per hour. Dragon Race is going in Pandora Village.

You are given an array A[] of size N, where A[i] denotes the Flying speed of the iᵗʰ Dragon.

Jake is going to compete with everyone. At the end of the competition, the final score of Jake will be evaluated

The evaluation Scheme is given as follows:

If the participant wins the race with his competitor he gets 5 points if he loses 2 points are deducted and if no one wins i.e. match draw then both the participants will get 2 points.

You have to find the final Score of Jake. As Jake is quite dumb in Maths help him to find his final score.

EXPLANATION :

In this example we have to calculate the final score of Jake who is quite dumb in Maths.

The problem is that we are given an array A[] of size N, where A[i] denotes the Flying speed of the iᵗʰ Dragon , where the Dragon of Jake is exactly 100 kmph.

Jake is going to compete with everyone(A[]),and the final score of Jake will be evaluated as

  • if Jake wins the race with his competitor (i) he gets (+)5 points

  • if Jake loses the race with his competitor (i) he gets (-)2 points are deducted and

  • if no one wins i.e. match draw then both the participants(i.e. jake and ith participant) will get (+)2 points.

and At the end of the competition, the evaluated final score of Jake will have to display in output.

TIME COMPLEXITY:

O(n)

SOLUTION :

Editorialist's solution(C++)

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it