Saleh127

codeforces 1365B.cpp

Jun 8th, 2020
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define Faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. #define pi acos(-1)
  7. #define yes printf("YES\n");
  8. #define no printf("NO\n");
  9. int main()
  10. {
  11. Faster
  12. test
  13. {
  14. ll a[1000],c[1000],n,d=0,e=0,f=0,i,j,k,l;
  15. cin>>n;
  16. for(i=0;i<n;i++)
  17. {
  18. cin>>a[i];
  19. }
  20. for(i=0;i<n;i++)
  21. {
  22. cin>>c[i];
  23. if(c[i]) e++;
  24. else f++;
  25. }
  26. for(i=0;i<n-1;i++)
  27. {
  28. if(a[i]>a[i+1])
  29. {
  30. d=1;
  31. }
  32. }
  33.  
  34. if(!d || (e && f)) yes
  35. else no
  36. }
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment