我不会动态规划
核心思想小换大 大吃大 大不能吃小 要吃的有价值
代码如下
#include#include #include #include using namespace std; #define in = read() typedef long long ll; const ll size = 2000 + 100; ll n; ll a[size],b[size];inline ll read(){ ll num = 0 , f = 1; char ch = getchar(); while(!isdigit(ch)){ if(ch == '-') f = -1; ch = getchar(); } while(isdigit(ch)){ num = num*10 + ch - '0'; ch = getchar(); } return num*f;}int main(){ n in; for(int i=1;i<=n;++i) a[i] in; for(int i=1;i<=n;++i) b[i] in; ll h1 = 1, h2 = 1, t1 = n, t2 = n, ans = 0; sort(a+1,a+n+1); sort(b+1,b+n+1); for(int i=1;i<=n;++i){ if(a[t1] > b[t2]){ -- t1; -- t2; ans += 200; continue; } if(a[h1] > b[h2]){ ++ h1; ++ h2; ans += 200; continue; } if(a[t1] == b[h2]){ -- t1; ++ h2; continue; } ++ h1; -- t2; ans -= 200; } printf("%d\n",ans);}//COYG