### **Dragon Race Problem | Codehive Contest | 4th Problem**↵
↵
↵
**PROBLEM LINK :** [CodeHive/Dragon Race](https://www.hackerrank.com/contests/codehive/challenges/dragon-race/problem)↵
↵
**Author & Tester :** [ Vedant Patil](https://www.linkedin.com/in/vedant-patil-047194224/) ↵
↵
**Editorialist :** [Nivedita Birajdar](https://www.codechef.com/users/niveditavb)↵
↵
#### **DIFFICULTY :** ↵
CAKEWALK...↵
↵
↵
#### **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.↵
↵
#### **Input Format :**↵
↵
- The first line contains an integer N, the size of the array.↵
- The Second line contains the N space-separated integers, the flying speed of the dragons.↵
↵
#### **Constraints :**↵
↵
- 1 ≤ N ≤ 100↵
↵
- 1 ≤ Ai ≤ 212↵
↵
#### **Output Format :**↵
↵
Output the final score of Jake.↵
↵
#### **Sample Input :**↵
↵
↵
~~~~~↵
3↵
98 100 119↵
~~~~~↵
↵
↵
↵
↵
#### **Sample Output :**↵
↵
↵
~~~~~↵
5↵
~~~~~↵
↵
↵
↵
↵
#### **Explanation :**↵
Jake will win the race with the first dragon with a flying speed of 98, score = 5↵
↵
The match will be drawn with the second dragon with a flying speed of 100, score = (5) + (2) = 7↵
↵
Jake will lose the race with the third dragon with a flying speed of 119, score = (5) + (2) + (-2) = 5↵
↵
so final score of Jake will be, score = (5) + (2) + (-2) = 5↵
↵
#### **Solution :**↵
↵
↵
↵
<spoiler summary="Editorialist's solution(C++)">↵
```↵
#include <cmath>↵
#include <cstdio>↵
#include <vector>↵
#include <iostream>↵
#include <algorithm>↵
using namespace std;↵
↵
↵
int main() {↵
/* Enter your code here. Read input from STDIN. Print output to STDOUT */ ↵
int n,ans=0;↵
cin>>n;↵
int a[n];↵
for(int i=0;i<n;i++){↵
cin>>a[i];↵
}↵
for(int i=0;i<n;i++){↵
if(a[i]<100){↵
ans+=5;↵
}else if(a[i]==100){↵
ans+=2;↵
}else if(a[i]>100){↵
ans-=2;↵
}↵
}↵
cout<<ans;↵
return 0;↵
}↵
```↵
</spoiler>↵
↵
↵
↵
**PROBLEM LINK :** [CodeHive/Dragon Race](https://www.hackerrank.com/contests/codehive/challenges/dragon-race/problem)↵
↵
**Author & Tester :** [ Vedant Patil](https://www.linkedin.com/in/vedant-patil-047194224/) ↵
↵
**Editorialist :** [Nivedita Birajdar](https://www.codechef.com/users/niveditavb)↵
↵
#### **DIFFICULTY :** ↵
CAKEWALK...↵
↵
↵
#### **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.↵
↵
#### **Input Format :**↵
↵
- The first line contains an integer N, the size of the array.↵
- The Second line contains the N space-separated integers, the flying speed of the dragons.↵
↵
#### **Constraints :**↵
↵
- 1 ≤ N ≤ 100↵
↵
- 1 ≤ Ai ≤ 212↵
↵
#### **Output Format :**↵
↵
Output the final score of Jake.↵
↵
#### **Sample Input :**↵
↵
↵
~~~~~↵
3↵
98 100 119↵
~~~~~↵
↵
↵
↵
↵
#### **Sample Output :**↵
↵
↵
~~~~~↵
5↵
~~~~~↵
↵
↵
↵
↵
#### **Explanation :**↵
Jake will win the race with the first dragon with a flying speed of 98, score = 5↵
↵
The match will be drawn with the second dragon with a flying speed of 100, score = (5) + (2) = 7↵
↵
Jake will lose the race with the third dragon with a flying speed of 119, score = (5) + (2) + (-2) = 5↵
↵
so final score of Jake will be, score = (5) + (2) + (-2) = 5↵
↵
#### **Solution :**↵
↵
↵
↵
<spoiler summary="Editorialist's solution(C++)">↵
```↵
#include <cmath>↵
#include <cstdio>↵
#include <vector>↵
#include <iostream>↵
#include <algorithm>↵
using namespace std;↵
↵
↵
int main() {↵
/* Enter your code here. Read input from STDIN. Print output to STDOUT */ ↵
int n,ans=0;↵
cin>>n;↵
int a[n];↵
for(int i=0;i<n;i++){↵
cin>>a[i];↵
}↵
for(int i=0;i<n;i++){↵
if(a[i]<100){↵
ans+=5;↵
}else if(a[i]==100){↵
ans+=2;↵
}else if(a[i]>100){↵
ans-=2;↵
}↵
}↵
cout<<ans;↵
return 0;↵
}↵
```↵
</spoiler>↵
↵