#C5362. Adjusting Student Scores Based on Study Hours
Adjusting Student Scores Based on Study Hours
Adjusting Student Scores Based on Study Hours
You are given a number of students, along with two lists: one containing the number of hours each student studied and the other containing their initial scores. Your task is to adjust the scores according to the new scoring method.
The new scoring method works as follows:
First, pair each student's study hours with their initial score, and then sort these pairs in increasing order of study hours. Traverse the sorted list while maintaining a running maximum of the scores encountered so far. For each student in the sorted list, update their score to be the maximum score encountered up to that point.
This can be mathematically formulated as:
$$\text{updated_score}_i = \max_{j \le i} (\text{initial_score}_j) $$After processing, the adjusted scores should be output in the original order of the students.
Note: In the case where multiple students have the same number of study hours, the order of processing is determined by their original ordering. It is guaranteed that the input data is valid and that the number of students matches the size of the lists provided.
inputFormat
The input is given via standard input (stdin) and consists of the following:
- An integer N representing the number of students.
- A line containing N integers separated by spaces, where each integer represents the number of study hours for a student.
- A line containing N integers separated by spaces, where each integer represents the initial score of a student.
outputFormat
Output a single line to the standard output (stdout) containing N integers separated by a single space. Each integer represents the adjusted score of a student in the same order as the input.## sample
6
2 4 6 1 3 5
10 12 14 8 11 13
10 12 14 8 11 13