add #include<algorithm> because std::min,std::max