fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int maxn=2e5+1;
  4. int t,n;
  5. int s[maxn];
  6.  
  7.  
  8. struct NODE{
  9. int a,b;
  10. bool operator<(const NODE rhs)const{
  11. if(a==rhs.a)
  12. return b>rhs.b;
  13. return (a<=rhs.a)? b>rhs.b: a>rhs.a;
  14. }
  15. };
  16.  
  17. int main() {
  18. ios_base::sync_with_stdio(false);
  19. cin.tie(0);
  20. cin>>t;
  21. while(t--){
  22. NODE node[maxn];
  23. int s[maxn];
  24. cin>>n;
  25. for(int i=0;i<n;i++)
  26. cin>>node[i].a;
  27. for(int i=0;i<n;i++)
  28. cin>>node[i].b;
  29. for(int i=0;i<n;i++){
  30. int j=i+1;
  31. while(j<n){
  32. if(node[i].a>=node[j+1].a and node[i].b>=node[j+1].b)
  33. s[i]++;
  34. else
  35. break;
  36. j++;
  37. }
  38. }
  39. for(int i=0;i<n;i++)
  40. cout<<s[i]<<"\n";
  41. }
  42.  
  43.  
  44. return 0;
  45. }
Success #stdin #stdout 0.01s 5280KB
stdin
1

 5
 1 3 1 2 3
 2 2 1 3 1
 5
 1 1 1 1 1
 5 4 3 2 1
stdout
1
0
0
1
0