CODEVS 3027 (easy dp)