Advertisement
Guest User

horse

a guest
Aug 21st, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int N = 1004;
  5. int n, a[N], b[N], tmp[N];
  6.  
  7. void sol() {
  8.     sort(a+1, a+n+1); reverse(a+1, a+n+1);
  9.     sort(b+1, b+n+1);
  10.        
  11.     int res = 0;
  12.     for (int win = n; win >= 1; --win) {
  13.         for (int i = 1; i <= win; ++i) tmp[i] = a[i];
  14.         reverse(tmp+1, tmp+win+1);
  15.        
  16.         int Count = 0;
  17.         for (int i = 1; i <= win; ++i) {
  18.             if (tmp[i] > b[i]) Count++;
  19.         }
  20.         res = max(res, Count);
  21.     }
  22.     cout << res << '\n';
  23. }
  24.  
  25. int main() {
  26.     ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  27.     //freopen("horse.inp", "r", stdin);
  28.     //freopen("horse.out", "w", stdout);
  29.     freopen("input.txt", "r", stdin);
  30.  
  31.     cin >> n;
  32.     for (int i = 1; i <= n; ++i) cin >> a[i];
  33.     for (int i = 1; i <= n; ++i) cin >> b[i];
  34.  
  35.     sol();
  36.  
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement