#C10281. Calculate Total Scores
Calculate Total Scores
Calculate Total Scores
You are given a set of submissions from a coding competition. There are P participants and Q problems. Each submission is represented as a triplet (participant_id, problem_id, score), where participant_id and problem_id are 1-indexed. For every participant and each problem, only the highest score is considered. The total score of a participant is calculated as:
$$\text{Total Score} = \sum_{j=1}^{Q} \max(\text{score}_{ij})$$
where \(\max(\text{score}_{ij})\) is the maximum score the participant \(i\) achieved for problem \(j\) (if no submission was made for a problem, it is considered as 0). Your task is to compute and output the total score for each participant.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains two integers
P
andQ
, representing the number of participants and the number of problems. - The second line contains an integer
N
, the number of submissions. - Each of the next
N
lines contains three integers:participant_id
,problem_id
andscore
.
outputFormat
Output a single line containing P
integers separated by spaces. The i-th integer represents the total score of the participant with id i.## sample
3 4
7
1 1 70
1 1 85
1 2 90
2 1 60
3 2 75
3 3 80
3 3 95
175 60 170