fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. int tests;
  7. cin>>tests;
  8. while(tests--){
  9. long long r,g,b, x,y,z, sum=0;
  10. cin>>r>>g>>b;
  11. if(r>=g) {
  12. if(r>=b) {z=r; y=b;}
  13. else {z=b; y=r;}
  14. x=g;
  15. }
  16. else {
  17. if(g>=b) {z=g; y=b;}
  18. else {z=b; y=g;}
  19. x=r;
  20. }
  21. if(z==y) {
  22. sum+=x;
  23. z=z-(x/2);
  24. y=y-(x/2+x%2);
  25. sum+=y;
  26. }
  27. else if((z-y)<x) {
  28. sum+=(z-y);
  29. x=x-(z-y);
  30. z=y;
  31. sum+=x;
  32. z=z-(x/2);
  33. y=y-(x/2+x%2);
  34. sum+=y;
  35. }
  36. else {
  37. sum+=(x+y);
  38. }
  39. cout<<sum<<"\n";
  40. }
  41. return 0;
  42. }
Success #stdin #stdout 0s 4384KB
stdin
3
1 2 64
64 2 1
64 64 63
stdout
3
3
95