Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. //Permuting Two Arrays
  2. #include <cmath>
  3. #include <cstdio>
  4. #include <vector>
  5. #include <iostream>
  6. #include <algorithm>
  7. #include <unordered_set>
  8. #include <cstdint>
  9.  
  10. using namespace std;
  11.  
  12.  
  13. int main() {
  14. int64_t first[1000];
  15. int64_t second[1000];
  16. int64_t T,N,K;
  17.  
  18. std::cin>>T;
  19. while(T-- > 0){
  20. std::cin>>N;
  21. std::cin>>K;
  22.  
  23. for(int i = 0 ; i < N;i++){
  24. std::cin>>first[i];
  25. }
  26.  
  27. for(int i =0 ; i < N;i++){
  28. std::cin>>second[i];
  29. }
  30.  
  31. sort(first,first+N);
  32. sort(second,second+N);
  33. reverse(second,second+N);
  34.  
  35. bool flag = true;
  36. for(int i = 0 ; i < N;i++){
  37. if(first[i] + second[i] < K){
  38. flag = false;
  39. break;
  40. }
  41. }
  42.  
  43. if(flag == true)
  44. std::cout<<"YES";
  45. else
  46. std::cout<<"NO";
  47.  
  48. std::cout<<"\n";
  49. }
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement