?Accepted Max Profit Problem

But didn't consider some situation.