#K40922. Taco Maximum Daily Visits

    ID: 26750 Type: Default 1000ms 256MiB

Taco Maximum Daily Visits

Taco Maximum Daily Visits

In this problem, you are given n intervals representing a range of days in a year and the number of visits added on each day within that range. Each interval is described by three integers: the start day s, the end day e, and the number of visits v for each day in that interval. Your task is to determine the maximum total number of visits recorded on any single day in the year.

The visits for a day are computed as the sum of all contributions from intervals that cover that day. Formally, if we denote by f(d) the total visits on day d, then:

[ f(d)=\sum_{(s,e,v) \text{ s.t. } s\le d\le e} v ]

You need to process the input from stdin and output the maximum number of visits on any day to stdout.

inputFormat

The first line contains a single integer n representing the number of intervals. This is followed by n lines, each containing three space-separated integers: s, e, and v, where:

  • s is the starting day (1 ≤ s ≤ 365),
  • e is the ending day (s ≤ e ≤ 365), and
  • v is the number of visits added for each day in the interval.

outputFormat

Output a single integer which is the maximum number of visits accumulated on any single day of the year.

## sample
3
1 10 5
5 15 7
20 25 3
12