Advertisement
Saleh127

CF 1418B

Sep 16th, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);cout.tie(0);
  9.  
  10. test
  11. {
  12. ll n,i,j=0,k,l;
  13. cin>>n;
  14. vector<ll>a(n),c(n);
  15. for(i=0;i<n;i++)
  16. {
  17. cin>>a[i];
  18. }
  19. for(i=0;i<n;i++)
  20. {
  21. cin>>c[i];
  22. }
  23. vector<ll>ans;
  24. for(i=0;i<n;i++)
  25. {
  26. if(c[i]==0)
  27. {
  28. ans.push_back(a[i]);
  29. }
  30. }
  31. sort(ans.begin(),ans.end(),greater<int>());
  32. for(i=0;i<n;i++)
  33. {
  34. if(c[i])
  35. {
  36. cout<<a[i]<< " ";
  37. }
  38. else
  39. {
  40. cout<<ans[j]<<" ";
  41. j++;
  42. }
  43. }
  44. cout<<endl;
  45. }
  46.  
  47.  
  48. return 0;
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement