Scaling behavior for random walks with memory of the largest distance from the origin