eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Airplane Parking

Airplane Parking

During this economic crisis time, Jack has started an incredible new business related to air travel, a parking-lot for airplane. He bought a very large land to park airplanes. However the land is very narrow, so that the only way airplanes can go in or go out of the parking lot must be in the\textbf{ Last-In First-Out} fashion (see picture below). He only has spaces in the parking lot so he \textbf{cannot} take some airplane at the end out so that other airplanes can move. \includegraphics{https://static.e-olymp.com/content/06/060fb4eb73652efbff3a72f15c295c88922e920f.jpg} Because of the limitation of the parking lot, it is not possible to accommodate all requests for parking. Each request consists of the planned arrival time and planned departure time, which are the times the airplane arrives at the parking lot. An example below shows a request table for \textbf{4} planes. In this case, it is possible to accommodate airplane \textbf{1}, \textbf{2}, and \textbf{4}. But it is not possible to accommodate both airplanes \textbf{2} and \textbf{3}. It is possible that different planes plan to arrive or depart the parking lot at the same time. Jack has the best crews working with him, so that they will manage to arrange the plane to the parking lot in the best way that if it is possible to park and take out the planes they will be able to do it. Consider another example. Although airplane \textbf{5} and \textbf{6} arrive at the same time, Jack's crews know that airplane \textbf{5} will have to be out before airplane \textbf{6}, so when both airplanes arrive they put airplane \textbf{6} in first, following by airplane \textbf{5}. Given a list of parking requests, you want to find the maximum number of airplanes that can be parked in this parking lot, provided that they can only depart in the Last-In First-Out fashion. \InputFile The first line contains an integer \textbf{T}, the number of test cases (\textbf{1} ≤ \textbf{T} ≤ \textbf{5}). Each test case is in the following format. The first line starts with an integer \textbf{N} (\textbf{1} ≤ \textbf{N} ≤ \textbf{300}) denoting the number of airplanes. The next \textbf{N} lines describe the request table. Each line \textbf{1+i}, for \textbf{1} ≤ \textbf{i} ≤ \textbf{N}, contains two integer \textbf{S_i} and \textbf{T_i}, (\textbf{0} ≤ \textbf{S_i} < \textbf{T_i} ≤ \textbf{1000000000}) which are the planned arrival time and planned departing time for airplane \textbf{i}. \OutputFile For each test case, you program must output a single line consisting of one integer, the maximum number of airplanes that can be parked in Jack's parking lot.
Ліміт часу 1 секунда
Ліміт використання пам'яті 256 MiB
Вхідні дані #1
2
4
1 10
2 5
3 7
6 9
3
10 12
10 15
13 17
Вихідні дані #1
3
2