**CLOSED**↵
↵
Recently I encountered a problem in one of the coding rounds that I attended and as of yet I am unable to solve it, or even find a direction in which to tackle this. I've tried using greedy or dp but could not find any solution. I don't know what the difficulty of the problem might be, but I thought of sharing it anyway. **Any help would be appreciated.**↵
↵
**Problem Statement:**<br>↵
You are standing in an election for your college. To win the election you need to win maximum number of hostels out of N possible. Your friends come up with a strategy to help you win. According to them for a given hostel i (1<=i<=N) the campaigning in that hostel starts from day a[i]. You are given L (the end date for campaigning). To win in a particular hostel i, you can start campaigning in that hostel from a[i] onward (a[i] inclusive), but you need to campaign for at least b[i] days straight (without any breaks) to win in that hostel, such that your last campaigning day doesn't exceed L.↵
↵
**Constraints:**<br>↵
1<=T<=1000<br>↵
1<=N<=1000, 1<=L<=1000<br>↵
1<=a[i], b[i]<=1000<br>↵
↵
**Input:**<br>↵
T (testcases)<br>↵
N L<br>↵
a[1] b[1]<br>↵
a[2] b[2]<br>↵
...<br>↵
...<br>↵
a[N] b[N]<br>↵
↵
**Output:**<br>↵
X (Maximum hostels you could win)<br>↵
↵
**Sample Testcase:**<br>↵
_Input:_<br>↵
1<br>↵
2 10<br>↵
2 2<br>↵
2 7<br>↵
_Output:_<br>↵
2<br>↵
_Explanation:_<br>↵
You campaign from day 2 to day 8 in hostel 2 and from day 9 to day 10 in hostel 1.<br>↵
↵
↵
Recently I encountered a problem in one of the coding rounds that I attended and as of yet I am unable to solve it, or even find a direction in which to tackle this. I've tried using greedy or dp but could not find any solution. I don't know what the difficulty of the problem might be, but I thought of sharing it anyway. **Any help would be appreciated.**↵
↵
**Problem Statement:**<br>↵
You are standing in an election for your college. To win the election you need to win maximum number of hostels out of N possible. Your friends come up with a strategy to help you win. According to them for a given hostel i (1<=i<=N) the campaigning in that hostel starts from day a[i]. You are given L (the end date for campaigning). To win in a particular hostel i, you can start campaigning in that hostel from a[i] onward (a[i] inclusive), but you need to campaign for at least b[i] days straight (without any breaks) to win in that hostel, such that your last campaigning day doesn't exceed L.↵
↵
**Constraints:**<br>↵
1<=T<=1000<br>↵
1<=N<=1000, 1<=L<=1000<br>↵
1<=a[i], b[i]<=1000<br>↵
↵
**Input:**<br>↵
T (testcases)<br>↵
N L<br>↵
a[1] b[1]<br>↵
a[2] b[2]<br>↵
...<br>↵
...<br>↵
a[N] b[N]<br>↵
↵
**Output:**<br>↵
X (Maximum hostels you could win)<br>↵
↵
**Sample Testcase:**<br>↵
_Input:_<br>↵
1<br>↵
2 10<br>↵
2 2<br>↵
2 7<br>↵
_Output:_<br>↵
2<br>↵
_Explanation:_<br>↵
You campaign from day 2 to day 8 in hostel 2 and from day 9 to day 10 in hostel 1.<br>↵
↵