BUSYMAN - I AM VERY BUSY

I AM VERY BUSY

You are actually very busy man. You have a big schedule of activities. Your aim is to do as much as activities as possible.

In the given figure, if you go to date with crush, you cannot participate in the coding contest and you can’t watch the movie. Also if you play DotA, you can’t study for the exam. If you study for the exam you can’t sleep peacefully. The maximum number of activities that you can do for this schedule is 3. 

Either you can

  • watch movie, play DotA and sleep peacefully (or)
  • date with crush, play DotA and sleep peacefully

Input Specifications

The first line consists of an integer T, the number of test cases. For each test case the first line consists of an integer N, the number of activities. Then the next N lines contains two integers m and n, the start and end time of each activity.

Output Specifications

For each test case find the maximum number of activities that you can do.

Input Constraints

1 <= T <=10
1 <= N <= 100000
0 <= start < end <= 1000000

Example

Sample Input: (empty lines just for clarity)
3
3
3 9
2 8
6 9

4
1 7
5 8
7 8
1 8

6
7 9
0 10
4 5
8 9
4 10
5 7

Sample Output:
1
2
3

Added by:cegprakash
Date:2012-05-11
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64

hide comments
2016-08-28 15:18:50
For me, I can date my crush and watch movie at the same time. (if and only if I have a girl friend lol)
2016-08-27 10:28:26
can be done without pairs also
2016-08-07 08:50:24
Learnt STL pair:)
2016-07-21 09:33:58 Baqir khan
@iloveaakanksha Quite evident from your SPOJ UserName ;)
2016-06-30 15:31:11
apart from applying general [spoiler] use C++ STL by-
1)[spoiler]
2)[spoiler]
3)[spoiler]
This logic got my code AC in first Go :-)

Last edit: 2016-07-29 22:10:04
2016-06-25 14:16:26
basic [spoiler] :) ac in go

Last edit: 2016-07-29 22:10:22
2016-06-25 10:51:17
AC in PyPy.


Last edit: 2016-06-25 10:52:51
2016-06-10 22:23:04
Either you can :
* watch movie, play DotA and sleep peacefully (or)
* date with crush, play DotA and sleep peacefully
What we wish for: 2nd one
What we end up having: 1st one
:'(
2016-06-10 12:11:03
cakewalk problem on [spoiler]


Last edit: 2016-07-29 22:12:35
2016-06-09 17:35:48
too easy
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.