fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. long long t,l1,l2,l3,ans,vv;
  6. cin>>t;
  7. while(t--)
  8. {
  9. long long a[4];
  10. ans=0;
  11. cin>>a[0]>>a[1]>>a[2];
  12. sort(a,a+3);
  13. l1=a[0];
  14. l2=a[1];
  15. l3=a[2];
  16. if((l3-l2)>l1)
  17. cout<<(l1+min(l2,l3-l1));
  18. else
  19. {
  20. ans+=(l3-l2);
  21. l1=l1-(l3-l2);
  22. l3=l2;
  23. vv=l1/2;
  24. if(l1%2==1)
  25. vv=l1/2+1;
  26. ans+=(l1+(l3-vv));
  27. cout<<ans;
  28. }
  29. cout<<'\n';
  30. }
  31. }
Success #stdin #stdout 0s 4360KB
stdin
6
1 1 1
1 2 1
4 1 1
7 4 10
8 1 4
8 2 8
stdout
1
2
2
10
5
9