Filling Jars

0

0 votes
Problem

Animesh has N empty candy jars, numbered from 1 to N, with infinite capacity. He performs M operations. Each operation is described by 3 integers, a, b, and k. Here, a and b are indices of the jars, and k is the number of candies to be added inside each jar whose index lies between a and b (both inclusive). Can you tell the average number of candies after M operations?


Input Format:
The first line contains two integers, N and M, separated by a single space.
M lines follow; each of them contains three integers, a, b, and k, separated by spaces.


Output Format:
A single line containing the average number of candies across N jars, rounded down to the nearest integer.


Constraints:
3 ≤ N ≤ 107
1 ≤ M ≤ 105
1 ≤ a ≤ b ≤ N
0 ≤ k ≤ 106

Time Limit: 2
Memory Limit: 256
Source Limit:
Editor Image

?