fork download
  1. #include <cstdio>
  2. #include <iostream>
  3. #include <cstring>
  4. #include <cmath>
  5. #include <algorithm>
  6. #include <fstream>
  7. #include <cstdlib>
  8. #include <functional>
  9.  
  10. #define rep( i, l, r ) for (int i = l; i <= r; i++)
  11. #define down( i, l, r ) for (int i = l; i >= r; i--)
  12. #define MS 100009
  13. #define MAX 2147483647
  14.  
  15. using namespace std;
  16.  
  17. int n, a[MS], b[MS], c;
  18.  
  19. int calc()
  20. {
  21. int s, t, x, y, ans = 0;
  22. s = x = 1; t = y = n;
  23. while (s <= t)
  24. {
  25. if (a[s] > b[x]) ans += 2, s++, x++;
  26. else if (a[t] > b[y]) ans += 2, t--, y--;
  27. else ans +=(a[s] == b[y]), s++, y--;
  28. }
  29. return ans;
  30. }
  31.  
  32. int main()
  33. {
  34. scanf("%d", &n);
  35. rep(i, 1, n) scanf("%d", &a[i]); sort(a+1, a+1+n);
  36. rep(i, 1, n) scanf("%d", &b[i]); sort(b+1, b+1+n);
  37. cout << calc() << ' ';
  38. rep(i, 1, n) c = a[i], a[i] = b[i], b[i] = c;
  39. cout << 2*n-calc() << endl;
  40. }
  41.  
Success #stdin #stdout 0s 4128KB
stdin
2
1 3
2 4
stdout
2 0