CODEVS 1044 (easy dp)