# [C++ (clang)], <sup><s>280</s> \$\cdots\$ <s>217</s></sup> 212 bytes <!-- language-all: lang-cpp --> #import<regex> #define S(v)std::sort(&v[0],&*end(v)); using V=std::vector<int>;void f(V&v){V r=v;S(v)int m=v.back(),n=m,t;for(int a:r)for(int b:r)for(int c:r){V x={a,b,c};S(x)t=x[2]-x[0];v=t<m&a+b+c==n?m=t,x:v;}} [Try it online!][TIO-kxs6s5ru] [C++ (clang)]: http://clang.llvm.org/ [TIO-kxs6s5ru]: https://tio.run/##1dTdjqIwFAfwe5/ixEkIjNWMfCPgXmz2CTbxxvECobpkFAxUlqzh1df9t@hKMjPZ6zVh0ml/nJ6etqSn0zQ9JMX@en3Kj6eyElHF97xdjp4yvssLTt/1xqhFtljUGNS1Zv2yYdozLzL0G@HoXOfFnlaxIg1PRVlFeSGWYVPmGe30ldYYlxVVcRPKSBiiY9zMtkn6phusiI9MhLuy0uVAsqiMe3s7aKdoI0YbXxK2ZWmHSK0h4nZtbqYt8gmbWERHLZlsJ2kcF1@OsWDtogm7Dosq0sM54xTlZS0qnhyXn6c8UtkleaEblxHhl5ZFjel/JNUz/vL0jVfrDcV0Gb@238zXNviKxxkzGv5vjbtQvT2Mv1qS4LWo5cuXOSOLkcvIYzS3Okayx2Tk9D3zRw@Yrfp77DMKAF7egX@@IcPiMeWEeEDmMHOguZwSbA5nwpkyDpwJZ8KZcCacCWfCmXAWnCVXISeEs@AsOAvOgrPgLDgbzoaz4WyZGZwNZ8PZcDacDefAOXCOLAKcI5cA58A5cA6cA@fCuXAunCtLCOfKtcK5cC6cC@fBeXAenAfnwXmyurIocB6cB@fD@XA@nA/nw/lwPpwvqwfnwwVwAVwAF8AFcAFcABfABbLMqs73ren3oN@PQG2D12@D@wD@YEPcW/Flwb3u4wPE2xPaPFNnyFKhvVs053YG@l77cRxM1Wvdt@m9UbNb9xlx40hdubzIeIuJXsJbM@rP76zOf3HdCGkyUf0G9TdF/lYk8IZiazW4Cf@OqaWk5VlQFNF4PX6MqCn7i5acRalRLipakBhGfhdB16SKY9KexWzL9/LK0hcaj/GmvI6GRCCPabpPUtnQdEnDdHRh/BdpD3JZEUfh78fj49qrrze/T8qIz@Qn3BisdVuWBzoltfxGcZmk@KQO9y@htBuVzWtxy6Ybddff6e6Q7Ovr9Ocf "C++ (clang) – Try It Online" _Saved 3 bytes thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat)!!!_ Inputs a vector of integers. Replaces the input vector with the cartesian product of 3 elements of the input vector that add up to the maximum of the input vector and that have the minimum difference between the smallest and the largest element from all of the cartesian products.