1 条题解
-
0Guest LV 0 MOD
-
1
#include "iostream" #include "cstdlib" #include "cstdio" #include "cstring" #include "algorithm" using namespace std; #define MAXN 10005 struct Node{ int a,b,c; friend bool operator<(const Node &x, const Node &y){ if(x.a<x.b&&y.a<y.b){ if(x.a==y.a)return x.c<y.c; return x.a<y.a; } else if(x.a>x.b&&y.a>y.b){ if(x.b==y.b)return x.c<y.c; return x.b>y.b; } else if(x.a==x.b&&y.a==y.b) return x.c<y.c; else if(x.a<x.b)return true; else if(y.a<y.b)return false; else return x.a==x.b; } }x[MAXN]; int n; int main(){ freopen("prod.in","r",stdin); freopen("prod.out","w",stdout); scanf("%d",&n); for(int i=1;i<=n;++i)scanf("%d",&x[i].a),x[i].c=i; for(int i=1;i<=n;++i)scanf("%d",&x[i].b); sort(x+1,x+n+1); int tb=0,ta=0; for(int i=1;i<=n;++i){ ta+=x[i].a; tb=max(ta,tb)+x[i].b; } cout << tb << endl; // for(int i=1;i<=n;++i) // printf("%d%c",x[i].c," \n"[i==n]); return 0; }
- 1