Sun Bin said: "Online practice is good trouble ...
Tips:
1. The topic is n<=1000, actually there is no need to go to pit O (n) greedy algorithm is it?
2. Enumeration I'm going to lose a few games, then the losing game according to Sun Bin's strategy must be with my worst of those horses to play the best horse son
3. Other horses must be matched in order of speed and size one by one to prove the method is not difficult to think, I started: Assuming that the first K has been well-matched, if at this time the speed of this one is less than the speed of the Zi Pang, then ...
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <algorithm>
using namespace std;
const int MAXN = 1100;
int n;
int A[MAXN];
int B[MAXN];
inline bool Judge (int D, int& Mon)
{
mon = 0;
for (int i=0;i<n-d;i++) if (A[i]>b[d+i]) return false; else mon+= (a[i]==b[d+i]?0:200);
return true;
}
int main (int argc, char *argv[]) {while
(cin>>n && N)
{for
(int i=0;i<n;i++) cin> >b[i];
for (int i=0;i<n;i++) cin>>a[i];
Sort (A, a+n);
Sort (b, b+n);
int res =-(1<<29), Mon;
for (int i=0;i<=n;i++) if (judge (I, Mon)) res = max (res, mon-i*200);
cout<<res<<endl;
}
return 0;
}