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
2019-08-11 10:21:44
AC in one go !!
try using [spoiler that won't help you] , things are even further simpler with its use , just a [spoiler] and ur done . Happy Coding ;)

Last edit: 2019-09-30 14:43:51
2019-07-25 12:37:49
[spoiler] implementation question

Last edit: 2019-09-30 14:46:43
2019-07-12 11:07:43
USE VECTOR<PAIR>
2019-06-01 14:28:53
AC in one go
Used [spoiler], vectors, pairs

Last edit: 2019-06-20 12:39:38
2019-04-29 05:08:08
TLE using Python 3, sadness about Python :(
Switched to Python 2 with pypy and ACed, luckily don't need to implement it in C++
2019-03-02 10:35:52
i do ont know why i am getting runtime error (sigsegv) besides the code achieving output in online compiler of c++ 14
2019-02-15 12:40:55
[spoiler] :-)


Last edit: 2019-03-11 23:40:20
2019-01-15 19:50:36
nice question
AC in one go
Yipeee
@ayushgupta1997 haha

Last edit: 2019-01-15 19:51:39
2018-12-28 12:27:55
Prefer sleeping than dating a crush lol :\
2018-08-30 16:14:55
I'm getting a WA and I'm not sure why? It seems to be working fine when I type in the above test case(without the empty lines of course). Any help would be much appreciated.

Last edit: 2018-08-30 16:15:26
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.