441. Corporate Flight Bookings
MediumPrefix Sum
There are n flights numbered 1..n. Each booking reserves seats on every flight from first to last. Print the total seats on each flight.
Input format
Line 1: n m Next m lines: first last seats
Output format
n totals.
Example 1
Input
5 3 1 2 10 2 3 20 2 5 25
Output
10 55 45 25 25
Example 2
Input
2 2 1 2 10 2 2 15
Output
10 25
Constraints
1 ≤ n, m ≤ 10⁵
Read input from standard input and print the answer to standard output. Your code is judged against 3 test cases, most of them hidden.
Loading the MyLoginn IDE…