# [bzoj3190][单调栈]赛车

Description

Input

Output

Sample Input

4

1 1 0 0

15 16 10 20

Sample Output

3

1 2 4

HINT

2016.1.17新加数据一组 By Nano_ape

1：斜率比栈顶不小，且出发点比栈顶高
2：这条直线与栈中第二个顶这条直线能完全遮蔽该直线，注意不能交于一点！

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
struct node
{
double k,b;//y=kx+b
int op;
}a[11000];int n,len;
bool cmp(node n1,node n2){return n1.k!=n2.k?n1.k<n2.k:n1.b<n2.b;}
double getpt(int u,int v){return (a[u].b-a[v].b)/(a[v].k-a[u].k);}
int sta[11000],tp;
int ans[11000];
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%lf",&a[i].b);
for(int i=1;i<=n;i++)scanf("%lf",&a[i].k),a[i].op=i;
sort(a+1,a+1+n,cmp);
sta[++tp]=1;
for(int i=2;i<=n;i++)
{
while(tp)
{
if(a[i].k==a[sta[tp]].k && a[i].b==a[sta[tp]].b)break;
double fx=getpt(i,sta[tp]),gx=getpt(sta[tp],sta[tp-1]);
if((a[i].k>=a[sta[tp]].k && a[i].b>a[sta[tp]].b) || fx<gx)tp--;
else break;
}
sta[++tp]=i;
}
for(int i=1;i<=tp;i++)ans[i]=a[sta[i]].op;
sort(ans+1,ans+1+tp);
printf("%d\n",tp);
for(int i=1;i<tp;i++)printf("%d ",ans[i]);
printf("%d\n",ans[tp]);
return 0;
}