fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const int Mod=998244353;
  5.  
  6. bool f(int mid , int a , int b , int c){
  7. if(a>=mid && b>=mid && (a+b+c)/3>=mid ) return true;
  8. return false;
  9. }
  10.  
  11. void solve() {
  12.  
  13. int c,m,x;
  14. cin >> c >> m >> x;
  15. int low=min(c,min(m,x)),high=max(c,max(m,x));
  16. int ans =low;
  17. while(low<=high){
  18. int mid=(low+high)/2;
  19. if(f(mid,c,m,x)){
  20. ans=mid;
  21. low=mid+1;
  22. }
  23. else
  24. high=mid-1;
  25. }
  26.  
  27. cout << ans << '\n';
  28. }
  29.  
  30. int main(){
  31. ios::sync_with_stdio(false);
  32. cin.tie(nullptr);
  33.  
  34. int t;
  35. cin >> t;
  36. while (t--) solve();
  37.  
  38.  
  39. return 0;
  40. }
  41.  
Success #stdin #stdout 0.01s 5308KB
stdin
6
1 1 1
3 6 0
0 0 0
0 1 1
10 1 10
4 4 1
stdout
1
3
0
0
1
3