size_t is unsigned. add sub_cost and use it instead of "changing sign"