看了黄学长的 每辆车可以表示成一个一次函数
y=kx+b
, 按
k
为第一关键字,
#include<bits/stdc++.h>
#define bug(x) cout<<(#x)<<" "<<(x)<<endl
#define ll long long
#define eps 1e-7
using namespace std;
const int N=2e4+5;
inline int read(){
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int r,n;
struct node{
int g,v,id;
}a[N],tmp[N];
bool cmp1(node a,node b){
return a.v==b.v?a.g<b.g:a.v<b.v;
}
bool cmp2(node a,node b){
return a.id<b.id;
}
double judge(node a,node b){
return (double)(a.g-b.g)/(double)(b.v-a.v);
}
int main(){
#ifdef Devil_Gary
freopen("in.txt","r",stdin);
#endif
n=read();
for(int i=1;i<=n;i++) a[i].g=read(),a[i].id=i;
for(int i=1;i<=n;i++) a[i].v=read();
sort(a+1,a+n+1,cmp1);
tmp[++r]=a[1];
for(int i=2;i<=n;i++){
while(r&&judge(tmp[r],a[i])<-eps) r--;
while(r>=2&&judge(tmp[r-1],tmp[r])>judge(tmp[r],a[i])) r--;
tmp[++r]=a[i];
}
sort(tmp+1,tmp+1+r,cmp2);
cout<<r<<endl;
for(int i=1;i<=r;i++){
cout<<tmp[i].id;
if(i!=r) cout<<" ";
}
}