IMPORTANT UPDATE! 5/19
TESTCASES HAVE BEEN UPDATED. PLEASE USE THE FOLLOWING METHOD FOR COMPARISON TO PREVENT FLOATING POINT PRECISION ERROR :
#include <cmath>
const double EPS = 1e-9;
bool float_equal(double a, double b) {
return fabs(a - b) < EPS;
}
MINOR UPDATE 5/21
Adjusted Testcase 4,5,6,7. If you're AC previously you should be fine, but if you failed those test cases, it might be accepted now.
You are tasked with creating a leaderboard for a basketball competition.
Each player’s performance is recorded after each match with the following statistics:
A player may play multiple matches, and each match's stats are recorded. You need to maintain and update the player's statistics across all matches. Once a player has completed their matches, you need to update their statistics (Points, Rebounds, Assists, and Fouls) and sort them according to different criteria based on the commands provided
.
Your job is to calculate the overall performance for each player based on their averages across all games. After that, you will need to sort the players according to the command provided:
The overall performance of each player is calculated using the following weighted sum formula:
Overall Performance (All)=((Total Points×0.5)+(Total Rebounds×0.3)+(Total Assists×0.2)-(Total Fouls×0.2))/Total Matches
NOTE: You must round it to the closest 2 decimal places.
Hint : Try to use setprecision()
You need to #include <iomanip>
Where:
For test case 8-10 there will be a team leaderboard system. Whereas each player will be assigned to a team and each team has a numerical ID.
And each team will be ranked by average score
Team Average Score = Total Players Average Performance / Total Number of Players
Your boss told you this is optional, but you know that your boss is mean and he will deduct your salary if you don't meet his expectation (8/10 score).
Incase of Tie, sort by team ID.
A hint from your ex-senior who got fired: Notice that we have a lot of information to sort and it's often updated, try to choose a suitable sorting method!
All
Score
Rebound
Assist
Foul
Team
Play PlayerName T P R A F
IMPORTANT: You are not allowed to STL library in this homework.
For each command, output the top 3 players/teams based on the sorting criteria.
For the "Foul" command, sort players in ascending order of fouls (fewer fouls are better).