Seating
의견: 0
To earn some extra money, the cows have opened a restaurant in their barn specializing in milkshakes. The restaurant has N seats (1 <= N <= 500,000) in a row. Initially, they are all empty.
Throughout the day, there are M different events that happen in sequence at the restaurant (1 <= M <= 300,000). The two types of events that can happen are:
-
A party of size p arrives (1 <= p <= N). Bessie wants to seat the party in a contiguous block of p empty seats. If this is possible, she does so in the lowest position possible in the list of seats. If it is impossible, the party is turned away.
-
A range [a,b] is given (1 <= a <= b <= N), and everybody in that range of seats leaves.
Please help Bessie count the total number of parties that are turned away over the course of the day.
Line 1: Two space-separated integers, N and M.
Lines 2..M+1: Each line describes a single event. It is either a line of the form "A p" (a party of size p arrives) or "L a b" (all cows in the range [a, b] leave).
The number of parties that are turned away.
seating.inseating.out10 4
A 6
L 2 4
A 5
A 21Output details: Party #3 is turned away. All other parties are seated.
평가 및 의견
Seating
Log in to rate problems.
아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.
풀이 제출
Seating