Lookup for upperbound of ( cSum - K ) in hash
List < int > al = new List < int > ( ) ; int end = 0 ; foreach ( int it in cum_set ) { end = it ; al . Add ( it ) ; } al . Sort ( ) ; int sit = lower_bound ( al , cSum - K ) ;