Advertisement
Saleh127

CF 1311B

Aug 2nd, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int e=0;
  4. int main()
  5. {
  6. int a[10000],c[10000],d,e,f,i,j,k=0,l,t;
  7. cin>>t;
  8. while(t--)
  9. {
  10. cin>>d>>e;
  11. k=0;
  12. for(i=0; i<d; i++)
  13. {
  14. cin>>a[i];
  15. }
  16. for(i=0; i<e; i++)
  17. {
  18. cin>>c[i];
  19. }
  20. sort(c,c+e);
  21. for(i=0;i<d;i++)
  22. {
  23. for(j=0;j<e;j++)
  24. {
  25. if(a[c[j]]<a[c[j]-1])
  26. {
  27. swap(a[c[j]],a[c[j]-1]);
  28. }
  29. }
  30. }
  31. ///is_sorted(a,a+d) check;
  32. for(i=1;i<d;i++)
  33. {
  34. if(a[i]<a[i-1])
  35. {
  36. k=1;
  37. break;
  38. }
  39. }
  40. if(k) cout<<"NO"<<endl;
  41. else cout<<"YES"<<endl;
  42. }
  43. return 0;
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement