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