#P8948. Recovering Original Exam Scores

    ID: 22112 Type: Default 1000ms 256MiB

Recovering Original Exam Scores

Recovering Original Exam Scores

There are two examinations. The first exam consists of 4 problems with a maximum score of 400, and the second exam consists of 6 problems with a maximum score of 600. Each student's raw score on an exam is a nonnegative integer between 0 and the exam's full marks (inclusive).

There are n students. For the i-th student, let ai be the score on the first exam and bi be the score on the second exam. Let A and B be the highest scores among all students in the first and second exams respectively (with A \ne 0 and B \ne 0). The standard score for the i-th student is defined as

\( c_i = 1000\Big(\frac{a_i}{A} + \frac{b_i}{B}\Big) \)

with the result rounded to the nearest integer (standard rounding: round half up).

After the computation, only the standard scores \(c_1, c_2, \dots, c_n\) are preserved and the original raw scores are lost. Your task is to recover any valid set of original scores \(a_i\) and \(b_i\) that satisfy the following conditions:

  • For every student, \(0 \le a_i \le 400\) and \(0 \le b_i \le 600\).
  • Student 1 (Qiu) achieved the highest marks in both exams, meaning \(a_1 = 400\) and \(b_1 = 600\) (which guarantees \(c_1 = 2000\)).
  • For every other student (i > 1), \(c_i \in [10, 1990]\).

It is guaranteed that at least one valid solution exists. If multiple solutions exist, you may output any one of them.

inputFormat

The first line contains an integer n — the number of students.

The second line contains n space-separated integers \(c_1, c_2, \dots, c_n\) representing the standard scores of the students.

outputFormat

Output n lines. The i-th line should contain two space-separated integers: ai and bi, representing the recovered raw scores for the first and second exams respectively.

sample

3
2000 100 1500
400 600

0 60 400 300

</p>