#P2367. Teacher's Grading Challenge

    ID: 15639 Type: Default 1000ms 256MiB

Teacher's Grading Challenge

Teacher's Grading Challenge

A language teacher keeps making mistakes when writing grades. When she tries to adjust the scores, she ends up tired because she has to add extra points to some students repeatedly, while also keeping an eye on the minimum score. Your task is to assist her in this challenge.

Given a list of initial scores \(s_1, s_2, \dots, s_n\) and a series of operations, each of which adds \(p\) points to the score of the \(i^{th}\) student, calculate the minimum score after all operations are executed. Mathematically, after updating the scores as \(s_i = s_i + p\) for the corresponding student, you need to compute \(\min_{1 \leq i \leq n} s_i\).

inputFormat

The input is given as follows:

  • The first line contains two integers \(n\) and \(m\), where \(n\) is the number of students and \(m\) is the number of operations.
  • The second line contains \(n\) space-separated integers representing the initial scores \(s_1, s_2, \dots, s_n\).
  • Each of the next \(m\) lines contains two integers \(i\) and \(p\), indicating that \(p\) points are added to the score of the \(i^{th}\) student (1-indexed).

outputFormat

Output a single integer, which is the minimum score among all the students after performing all the operations.

sample

5 3
10 20 30 40 50
1 5
3 10
5 5
15