bool方法
#include<cstdio>
#include<algorithm>
#include<iostream>
#define maxn 4005
using namespace std;
struct node{
long long a,b; //在两个车间分别加工的时间
int num; //原来的下标
}q[maxn];
//1 相等 2 a大 3 b大
bool cmp(node x,node y)
{
if(min(x.a,y.b)<min(x.b,y.a)) return 1;
else if(min(x.a,y.b)>=min(x.b,y.a)) return 0;
}
int n;
int ans=0;
int main()
{
// freopen("scheduling.in","r",stdin);
// freopen("scheduling.out","w",stdout);
cin>>n;
for(int i=1;i<=n;i++)
{
scanf("%d",&q[i].a);
q[i].num=i;
}
for(int i=1;i<=n;i++)
{
scanf("%d",&q[i].b);
}
sort(q+1,q+1+n,cmp);
int n1=0,n2=0;
for(int i=1;i<=n;i++)
{
if(i!=1)
n1+=q[i].a;
if(i!=n)
n2+=q[i].b;
}
n1=max(n1,n2)+q[1].a+q[n].b;
cout<<n1<<endl;
for(int i=1;i<=n;i++)
cout<<q[i].num<<" ";
fclose(stdin);
fclose(stdout);
return 0;
}