记录编号 |
489787 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[JLOI 2013] 赛车 |
最终得分 |
100 |
用户昵称 |
LadyLex |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.074 s |
提交时间 |
2018-03-05 12:16:29 |
内存使用 |
0.41 MiB |
显示代码纯文本
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
#define N 10010
#define LL long long
#define db double
const db pi=acos(-1);
struct Vector
{
db x,y;
Vector(db a=0,db b=0){x=a,y=b;}
inline Vector operator + (const Vector &b){return Vector(x+b.x,y+b.y);}
inline Vector operator - (const Vector &b){return Vector(x-b.x,y-b.y);}
inline db operator * (const Vector &b){return x*b.y-y*b.x;}
inline Vector operator * (const db &b){return Vector(b*x,b*y);}
};
struct line{int s,v,id;}l[N];
int sta[N],top;
#define eps 1e-8
inline int sign(db a){return (a>-eps)-(a<eps);}
inline db delta(line a,line b)
{
return (db)(b.s-a.s)/(a.v-b.v);
}
inline bool mt (const line &a,const line &b)
{
return a.v==b.v?a.s<b.s:a.v<b.v;
}
char B[1<<15],*S=B,*T=B;
#define getc (S==T&&(T=(S=B)+fread(B,1,1<<15,stdin),S==T)?0:*S++)
inline int read()
{
int x=0;register char c=getc;
while(c<'0'|c>'9')c=getc;
while(c>='0'&c<='9')x=10*x+(c^48),c=getc;
return x;
}
int ans[N];int main()
{
freopen("race1.in","r",stdin);
freopen("race1.out","w",stdout);
register int i,j,n=read();
for(i=1;i<=n;++i)l[i].s=read();
for(i=1;i<=n;++i)l[i].v=read(),l[i].id=i;
sort(l+1,l+n+1,mt);
for(top=1,i=2;i<=n;++i)
if(l[top].v==l[i].v&&l[top].s!=l[i].s)l[top]=l[i];
else l[++top]=l[i];
n=top;
for(top=0,i=1;i<=n;++i)
{
while(top>0&&sign(delta(l[sta[top]],l[i]))<0)--top;
while(top>1&&sign(delta(l[sta[top-1]],l[sta[top]])-delta(l[sta[top-1]],l[i]))>0)--top;
sta[++top]=i,ans[top]=l[i].id;
}
sort(ans+1,ans+top+1);
for(printf("%d\n%d",top,ans[1]),i=2;i<=top;++i)
printf(" %d",ans[i]);
}