fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int a[6]={9,3,1,5,2,1};
  7. int b[4]={9,1,1,1};
  8. unordered_map<int,int>m1;
  9. unordered_map<int,int>m2;
  10. for(int i=0;i<6;i++){
  11. m1[a[i]]++;
  12. }
  13. for(int i=0;i<4;i++){
  14. m2[b[i]]++;
  15. }
  16. for(int i=0;i<4;i++){
  17. if(m1.find(b[i])!=m1.end()){
  18. if(m2[b[i]]>m1[b[i]]){
  19. cout<<"there does not exit pair";
  20. return 0;
  21. }
  22. }
  23. }
  24. cout<<"there exit pair";
  25. return 0;
  26. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
there does not exit pair