fork download
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. using namespace std ;
  4. const int mabu = 1e5+10;
  5. vector<ll>a(mabu);
  6. vector<ll>b(mabu);
  7. ll n , m ;
  8. int main()
  9. {
  10. ios_base::sync_with_stdio(false);
  11. cin.tie(0);
  12. cout.tie(0);
  13. freopen("MARBLE.INP","r",stdin);
  14. freopen("MARBLE.OUT","w",stdout);
  15. cin>> n;
  16. for(ll i = 0 ; i<n;i++)
  17. cin>>a[i];
  18. cin>>m;
  19.  
  20. for(ll j = 0 ; j<m;j++)
  21. cin>>b[j];
  22. ll cnt =0;
  23. ll tmp =0;
  24. ll tmp2=0;
  25. ll cnt2=0;
  26. ll res= -1e12;
  27. for(ll i =0 ; i <n;i++)
  28. {
  29. if(tmp>a[i])
  30. {
  31. res=max(res,cnt2+cnt);
  32. cnt=0;
  33. }
  34. else
  35. {
  36. tmp2=1e12;
  37. cnt2=0;
  38. for(ll j = m-1;j>=0;j--)
  39. {
  40. if(tmp2<b[j])
  41. {
  42. res=max(res,cnt2+cnt);
  43. cnt2=0;
  44. }
  45. else
  46. {
  47. cnt2++;
  48. }
  49. }
  50. res=max(res,cnt2+cnt);
  51. }
  52.  
  53. tmp=a[i];
  54. }
  55. cout<<res<<endl;
  56. return 0;
  57. }
Success #stdin #stdout 0.01s 5296KB
stdin
Standard input is empty
stdout
Standard output is empty