Nischal and Tasks Subsets

0

0 votes
Greedy Algorithms, Dynamic Programming and Bit Masking
Problem

Nischal has been given a list of tasks to do. Each task will take him exactly one day, and on each day he can only work on one of the tasks. The days on which he can do these tasks are numbered starting from 0 till 15. Each task has two parameters, start[i] is the first day on which he can do this task, and finish[i] is the last such day. He can choose which tasks he will perform and in which order.

In particular, he can always choose not to do any of the tasks(as he is lazy sometimes). You are given start and finish array. Calculate and return the number of different subsets of tasks Nischal may complete.

Note : task subset {1,2} is considered same as {2,1}. 


INPUT:

First line will contain N, representing the number of tasks given.

Second line will contain N space separated integers representing starting day of ith task

Third line will contain N space separated integers representing finishing day of ith task

OUTPUT: Print single integer as asked above

CONSTRAINTS:

1<=N<=100

0<=finish[i]<=15

0<=start[i]<=finish[i]

Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

Possible subsets are :

{}

{1}

{2}

{3}

{1,2}

{1,3}

{2,3}

All three tasks can not be performed.

Editor Image

?