fork download
  1. // ***Please Don't Write Blindly FUCK RATING ^=^ *** kailee
  2. #include<ext/pb_ds/assoc_container.hpp>
  3. using namespace std;
  4. #include<ext/pb_ds/tree_policy.hpp>
  5. #include<set>
  6. #include<iostream>
  7. #include<unordered_map>
  8. #include<vector>
  9. #include<climits>
  10. #include<cstring>
  11. #include<list>
  12. #include<ctime>
  13. #include<stack>
  14. #include<deque>
  15. #include<queue>
  16. #include<algorithm>
  17. #include<numeric>
  18. #include<map>
  19. #include<cstdlib>
  20. #include<cmath>
  21. #include <functional>
  22. #include <fstream>
  23. #include <random>
  24. #include <cassert>
  25. #include <unordered_set>
  26. #define deb(x) cout << #x<<'='<<x<<endl
  27. #define deb2(x, y) cout << #x << '=' << x << ',' << #y << '=' << y << endl
  28. #include <iomanip>
  29. #include <bitset>
  30. #include <sstream>
  31. #include <chrono>
  32.  
  33.  
  34. /*
  35. +--------------------------------------------Kailee------------------------------------------------------------------------------------------------------------+
  36.  #include <boost/multiprecision/cpp_int.hpp> namespace mp = boost::multiprecision; typedef mp::cpp_int ll; */
  37. #define IM INT_MAX
  38. #define IN INT_MIN
  39. #define ll long long int
  40. #define gc getchar_unlocked
  41. #define fo(i,a,n) for(int i=a;i<n;i++)
  42. #define fod(i,n,a) for(int i=n;i>=a;i--)
  43. #define vi vector<int>
  44. #define vl vector<ll>
  45. #define all1(x) x.rbegin(), x.rend()
  46. #define pb push_back
  47. #define mp make_pair
  48. #define F first
  49. #define in(XX,NN) for(int i=0;i<NN;i++)cin>>XX[i]
  50. #define tr(it,a) for(auto it:a)
  51. #define S second
  52. #define all(x) x.begin(), x.end()
  53. #define meme(x) memset(x, 0, sizeof(x))
  54. #define PI 3.1415926535897932384626
  55. #define FASTEST ios_base::sync_with_stdio(0);cin.tie(0);
  56. using namespace __gnu_pbds;
  57. typedef tree<pair<int,int> ,null_type,less<pair<int,int> > ,rb_tree_tag,tree_order_statistics_node_update>
  58. // typedef tree<int ,null_type,less<int> ,rb_tree_tag,tree_order_statistics_node_update>
  59. PBDS;
  60. const ll mod=1e9+7;
  61. const int max_size = int(1e6) + 5;
  62.  
  63. void solve(){
  64. int n;cin>>n;
  65. vector<pair<int,int>>v(n);
  66. if(n==0){cout<<0<<endl;return;}
  67. fo(i,0,n)cin>>v[i].F;
  68. fo(i,0,n)cin>>v[i].S;
  69. int ans=IN;
  70. fo(i,0,n){
  71. int c=1;
  72. auto last=v[i];
  73. fo(j,i+1,n){
  74. if(v[j].F>last.F&&v[j].S<last.S){c++;last=v[j];}
  75. // deb2(c,ans);
  76. }
  77. ans=max(ans,c);
  78. }
  79.  
  80. cout<<ans<<endl;
  81. return ;
  82. }
  83.  
  84.  
  85.  
  86.  
  87.  
  88. int main() {
  89. FASTEST
  90. /*
  91. sieve();
  92. 1e6>999999
  93. gcd{lcm{a,b},lcm{a,c}} = lcm{a,gcd{b,c}}
  94. */
  95. int t=1;
  96. cin>>t;
  97. while(t--){solve();}
  98. return 0;
  99. }
Success #stdin #stdout 0s 4716KB
stdin
Standard input is empty
stdout
0