fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_LENGTH = 10;
  5. const int TEN = 10;
  6.  
  7. int main() {
  8. int n;
  9. cin >> n;
  10. int freq[TEN] = {0};
  11. for (int i = 1; i <= n; ++i) {
  12. int no;
  13. cin >> no;
  14. while (no) {
  15. ++freq[no % TEN];
  16. no /= TEN;
  17. }
  18. }
  19. int counter1 = 0;
  20. for (int i = 0; i < TEN; ++i) {
  21. if (freq[i] == 0) {
  22. ++counter1;
  23. }
  24. }
  25. for (int i = 1; i <= n; ++i) {
  26. int no;
  27. cin >> no;
  28. while (no) {
  29. if (freq[no % TEN] != 0) {
  30. --freq[no % TEN];
  31. }
  32. no /= TEN;
  33. }
  34. }
  35. int countPairs = 0;
  36. for (int i = 0; i < TEN; ++i) {
  37. if (freq[i] == 0) {
  38. ++countPairs;
  39. }
  40. }
  41. cout << countPairs - counter1;
  42. return 0;
  43. }//
Success #stdin #stdout 0.01s 5288KB
stdin
5
1 1 1 2 2
2 2 2 1 1 
→ 0

5
1 2 3 4 5 
6 7 8 9 10
→ 1

5
5 5 5 5 5
5 5 5 5 5
→ 1

6
88 88 88 99 99 99
99 99 99 88 88 88
→ 2
Bustamante Thiago
9:27 PM
1
1
1 -> 1

1
10
10 -> 2

2
1 100
100 1 -> 2

5
1 2 3 4 5
5 4 3 2 1 -> 5

5
2 2 2 2 2
2 2 2 2 2 -> 1

10
1 100 100 1 1 100 100 1 100 1
100 1 100 1 100 1 100 1 100 1 -> 2

1
1
2 -> 0

2
1 100
99 2 -> 0

5
2 4 6 8 10
1 3 5 7 9 -> 1

5
2 2 2 2 2
2 3 3 3 3 -> 0

10
1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18 19 20 -> 8

5
45 45 45 45 45
54 54 54 54 54 -> 2

3
99 888 77      
99 80 77       -> 2

5
99 88 77 99 100
99 80 77 99 100
Date ieșire:
-> 3
stdout
1