The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 399 Weeks Ago, 1 Day Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
STATEMENT
For a long time you have been wanting to attend Waves and it is time for Lights, Camera, Mayhem! There are a lot of events taking place and you want to attend them all. Unfortunately, you might not be able to do that since some of them may take place at the same time. You have also decided that if you attend an event you want to stay for the whole duration of that event.
You decide that while you may not be able to attend them all, you will attend as many as you can. Given the schedule, try out figure out how many events that is.
NOTE: It will take you some time to get from one event to another, so if there are two events such that one ends exactly when another begins, you can not attend them both.
INPUT
The first line will contain an integer T, denoting the number of test cases.
Each test case contains several lines.
The first line of each test case will contain an integer N, denoting the number of events.
The next N lines, one for each event, contain two space separated integers, starttime and endtime.
1
1
0
OUTPUT
For each test case, output a single integer denoting the maximal number of events that you can attend.
EXAMPLE
2
5
0 5
0 2
3 5
3 4
5 6
6
0 8
8 10
11 12
11 15
2 5
7 9
3
3
In the first case you can attend events (0, 2), (3, 4), (5, 6)
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll