# [BZOJ3190]&&[JLOI2013] 赛车

4
1 1 0 0
15 16 10 20

## 样例输出 SampleOutput

3
1 2 4

BZOJ 3190

``````#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
const int maxn=10005;
int i,j,t,n,m,l,r,k,z,y,x;
struct car
{
int k,v,id;
bool operator > (const car& tmp) const
{
return (v==tmp.v)?(k>tmp.k):(v<tmp.v);
}
bool operator < (const car& tmp) const
{
return (id<tmp.id);
}
}a[maxn];
inline double crossx(car a,car b)
{
return (double)((double)a.k-b.k)/(double)(b.v-a.v);
}
vector <car> s;
int main()
{
scanf("%d",&n);
for (t=0,i=1;i<=n;i++) scanf("%d",&a[i].k),t=max(t,a[i].k);
for (i=1;i<=n;i++) scanf("%d",&a[i].v),a[i].id=i;
n++;
a[n]=(car){t,0,n};
sort(a+1,a+n+1,greater<car>());
s.clear();
for (i=1;i<=n;i++)
{
if (!s.empty() && a[i].v==s.back().v)
{
if (a[i].k==s.back().k) s.push_back(a[i]);
}
else
{
while (s.size()>1 && crossx(a[i],s.back())<crossx(s.back(),s[s.size()-2])) s.pop_back();
s.push_back(a[i]);
}
}
sort(s.begin(),s.end());
s.pop_back();
printf("%d\n",(int)s.size());
for (i=0;i<s.size()-1;i++) printf("%d",s[i].id);
printf("%d\n",s[s.size()-1].id);
return 0;
}``````