fork download
  1. //
  2. // main.cpp
  3. // B - Apartments
  4. //
  5. // Created by Farrah Tharwat on 28/01/2023.
  6. //
  7.  
  8. #include <iostream>
  9. #include <set>
  10. using namespace std;
  11. void farrouha(){
  12. ios_base::sync_with_stdio(false);
  13. cin.tie(NULL);
  14. cout.tie(NULL);
  15. }
  16. int main(int argc, const char * argv[]) {
  17. farrouha;
  18. int n,m,k,cnt=0;
  19. set <int> nn;
  20. set <int> mm;
  21. set <int> kk;
  22. cin>>n>>m>>k;
  23. while(n--){
  24. int x;
  25. cin>>x;
  26. nn.insert(x);
  27. }
  28. while(m--){
  29. int x;
  30. cin>>x;
  31. mm.insert(x);
  32. }
  33. set <int>::iterator i;
  34. for(i=nn.begin(); i!=nn.end(); i++){
  35. if(mm.count(*i)||mm.count((*i)+5)||mm.count((*i)-5))
  36. cnt++;
  37. }
  38. cout<<cnt<<"\n";
  39. }
  40.  
Success #stdin #stdout 0.01s 5536KB
stdin
4 3 5
60 45 80 60
30 60 75
stdout
2