Solution :

1)Sort the given array .

2)Traverse the array , say you are at index 'i' , observe a[i] , we want to find a[j], such that a[i] + a[j] < = m ,

which means : a[j]<=m-a[i].

3)Let y = m - a[i] . Binary search 'y' in rage [1,i-1] of array 'a' . So you found out value of a[i] + a[j] < = m , do this for all indices 'i' and output the maximum of all of them .