#K65777. Maximum Server Health After Repairs

    ID: 32273 Type: Default 1000ms 256MiB

Maximum Server Health After Repairs

Maximum Server Health After Repairs

In an operation involving \( n \) servers, each server begins with an initial health given by an array \( health \). There are \( m \) repair operations, where each repair is defined by three integers \( s_i \), \( e_i \), and \( r_i \). Each repair increases the health of every server from index \( s_i \) to \( e_i \) (inclusive) by \( r_i \). Your task is to compute the maximum health value among all servers after applying all repairs. The effect of each repair is cumulative, and improvements from different teams add up.

inputFormat

The first line contains two integers \( n \) and \( m \), the number of servers and the number of repair operations respectively. The second line contains \( n \) space-separated integers representing the initial health values of each server. Each of the next \( m \) lines contains three integers \( s_i \), \( e_i \), and \( r_i \) describing a repair operation.

outputFormat

A single integer denoting the maximum health value among all servers after applying all repairs.

## sample
5 3
10 20 30 40 50
1 3 15
2 5 20
3 4 25
90