fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <map>
  5. #include <bits/stdc++.h>
  6.  
  7. using namespace std;
  8.  
  9. #define saleh \
  10.   ios_base::sync_with_stdio(false); \
  11.   cin.tie(nullptr);
  12. #define ll long long
  13.  
  14. int main()
  15. {
  16.  
  17. saleh;
  18.  
  19. int t;
  20. cin >> t;
  21. while (t--)
  22. {
  23. int n, m;
  24. cin >> n >> m;
  25.  
  26. int m1[16]={0};
  27. int m2[51]={0};
  28.  
  29. int c=0;
  30. for(int x=0;x<n;x++)
  31. {
  32. int r;
  33. cin>>r;
  34.  
  35. m1[r]++;
  36. if(m1[r]==1)
  37. c++;
  38. }
  39.  
  40. for(int x=0;x<m;x++)
  41. {
  42. int r;
  43. cin>>r;
  44.  
  45. m2[r]++;
  46. }
  47.  
  48. int l=5,r=1;
  49. for(int x=l;x<16;x++)
  50. {
  51. if(m1[x]==0)continue;
  52. while(r<51&&m1[x]>m2[r])
  53. {
  54. r++;
  55. }
  56. if(r==51)
  57. break;
  58. r++;
  59. c--;
  60.  
  61. }
  62. if(c==0)
  63. cout<<"YES\n";
  64. else
  65. cout<<"NO\n";
  66.  
  67.  
  68.  
  69. }
  70. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty