一道站外题,我想知道我哪里做错了
有N盆植物,第i盆植物初始高度为hi,每天长vi,求最少要几天能够使得对于所有1≤i≤N有ti盆植物比第i盆高(若没有则输出−1)?
本题有多组数据
第一行输入一个整数T,表示有T组独立的数据
每组数据中:
第一行输入一个整数N
第二行输入N个整数,第i个表示hi
第三行输入N个整数,第i个表示vi
第四行输入N个整数,第i个表示ti
1≤T≤10,1≤N≤2⋅105,1≤hi≤109,1≤vi≤109,ti为1到N−1的一个排列
6
1
10
1
0
2
7 3
8 10
1 0
2
3 6
10 8
0 1
2
7 3
8 9
1 0
2
7 7
8 8
0 1
2
7 3
8 8
1 0
0
3
2
5
-1
-1
2
5
7 4 1 10 12
3 4 5 2 1
2 1 0 3 4
5
4 10 12 7 1
3 1 1 4 5
2 4 3 1 0
4
7
#include<bits/stdc++.h>
#define int long long
#define double long long
using namespace std;
struct plant{
int h,v,t;
}p[200005];
void init(){
for(int i=0;i<=200005;i++) p[i].h=p[i].t=p[i].v=0;
}
bool cmp(plant x,plant y){
return x.t<y.t;
}
signed main(){
int t;
cin>>t;
for(int k=1;k<=t;k++){
int n;
cin>>n;
init();
for(int i=1;i<=n;i++) cin>>p[i].h;
for(int i=1;i<=n;i++) cin>>p[i].v;
for(int i=1;i<=n;i++) cin>>p[i].t;
sort(p+1,p+n+1,cmp);
if(n==1){
cout<<0<<endl;
continue;
}
int maxn1=0,maxn2=114514;
bool flag=false;
for(int i=2;i<=n;i++){
if(p[i].h>=p[i-1].h&&p[i].v>=p[i-1].v){
flag=true;
break;
}
else if(p[i].h<=p[i-1].h&&p[i].v>p[i-1].v){
int x=(p[i-1].h-p[i].h),y=(p[i].v-p[i-1].v);
x=x/y+1;
maxn2=min(maxn2,x);
}
else{
int x=(p[i].h-p[i-1].h),y=(p[i-1].v-p[i].v);
if(y==0){
x==0;
}
else x=x/y+1;
maxn1=max(maxn1,x);
}
}
// cout<<maxn1<<" "<<maxn2<<" "<<flag<<endl;
if(flag||maxn2<=maxn1){
cout<<-1<<endl;
continue;
}
cout<<maxn1<<endl;
}
}
这段代码能过样例但交上去是WA