题解
很巧妙,把等式移项之后,ab差最大的就是答案
code
#include<bits/stdc++.h>
using namespace std;
#define ll long long
struct node
{
int a,b,df,id;
}c[200005];
bool cmp(node x,node y)
{
if(x.df!=y.df) return x.df>y.df;
else return x.id<y.id;
}
int main()
{
int t=1;
cin>>t;
while(t--)
{
ll n;
cin>>n;
for(ll i=1;i<=n;i++)
{
cin>>c[i].a;
}
for(ll i=1;i<=n;i++)
{
cin>>c[i].b;
c[i].df=c[i].a-c[i].b;
c[i].id=i;
}
sort(c+1,c+1+n,cmp);
ll f=c[1].df;
int i;
for(i=1;i<=n;i++)
{
if(c[i].df<f) break;
}
cout<<i-1<<endl;
for(int j=1;j<i;j++) cout<<c[j].id<<" ";
puts("");
}
return 0;
}
标签:node,df,ll,Vertices,long,int,Strong,id
From: https://www.cnblogs.com/pure4knowledge/p/18196598