#FT0000241. Đặt chỗ trên các chuyến bay (Corporate Flight Bookings)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Đặt chỗ trên các chuyến bay (Corporate Flight Bookings)
Corporate Flight Bookings
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
An airline operates flights, numbered consecutively from to . There are booking records. Booking contains three integers .
Booking reserves an additional seats on every flight numbered from through , inclusive. For example, reserving seats on flights through adds reservations to each of flights , , and ; the seats are not divided among those flights.
After processing all bookings, determine the total reserved seats for each flight separately. A flight mentioned in no booking has result .
Input
- The first line contains integers : the number of flights and the number of bookings.
- Each of the next lines contains integers : the first flight, last flight, and seats reserved on each flight in the inclusive range .
Output
Print exactly space-separated integers on one line. Value is the total seats reserved for flight .
Subtasks
- Subtask 1 (20 points): ; ; and for every booking.
- Subtask 2 (30 points): ; ; and for every booking.
- Subtask 3 (50 points): ; ; and for every booking.
Examples
Input
5 3
1 2 10
2 3 20
2 5 25
Output
10 55 45 25 25
Explanation
There are flights and bookings:
- Booking produces .
- Booking produces .
- Booking produces .
Flight has reserved seats; flight has . The other flight totals are , , and .