class Solution {
public:
int fillCups(vector<int>& amount) {
sort(amount.begin(), amount.end());
int loww=amount[0], low=amount[1], lar=amount[2];
int sum=low+loww+lar;
if(lar<loww+low) return sum/2+sum%2;
else return lar;
}
};
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter