Taking the first k customers that can be satisfied by total amount d
for i in range ( n ) : NEW_LINE INDENT if v [ i ] [ first ] <= d : NEW_LINE INDENT ans . append ( v [ i ] [ second ] ) NEW_LINE d -= v [ i ] [ first ] NEW_LINE DEDENT DEDENT print ( len ( ans ) ) NEW_LINE for i in range ( len ( ans ) ) : NEW_LINE INDENT print ( ans [ i ] , end = " ▁ " ) NEW_LINE DEDENT