思路:即求取K个元素之和大于剩下的元素之和,按A排序,两个两个地按B选择。
# include <bits/stdc++.h>
using namespace std;
int a[1<<20], b[1<<20], c[1<<20], d[1<<20];
int main()
{
int n, cnt=0;
scanf("%d",&n);
for(int i=0; i<n; ++i) scanf("%d",&a[i]);
for(int i=0; i<n; ++i) scanf("%d",&b[i]);
for(int i=0; i<n; ++i) c[i] = i;
sort(c, c+n, [&](int x, int y){return a[x] > a[y];});
d[cnt++] = c[0];
for(int i=1; i<n; i+=2)
{
int t = c[i];
if(i+1<n && b[c[i+1]] > b[t])
t = c[i+1];
d[cnt++] = t;
}
printf("%d\n",cnt);
for(int i=0; i<cnt; ++i) printf("%d ",d[i]+1);
return 0;
}