QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#129283 | #5505. Great Chase | Forever_Young# | WA | 2ms | 10036kb | C++14 | 1.1kb | 2023-07-22 13:48:47 | 2023-07-22 13:48:48 |
Judging History
answer
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int t,n,v,tail[2],b[2][400040];
LL a[2][400040];
double l,r;
int check(double x){
double ma[2];
ma[0]=a[0][0];
for (int i=0;i<tail[0];i++)
ma[0]=max(ma[0],a[0][i]+b[0][i]*x);
ma[1]=a[1][0];
for (int i=0;i<tail[1];i++)
ma[1]=min(ma[1],a[1][i]-b[1][i]*x);
//printf("%.9lf %.9lf %.9lf\n",x,ma[0],ma[1]);
if (ma[0]>ma[1]) return 1;
return 0;
}
int main(){
scanf("%d",&t);
while (t--){
scanf("%d%d",&n,&v);
tail[0]=tail[1]=0;
for (int i=0;i<n;i++){
LL tmpa;
int tmpb,typ;
scanf("%lld%d",&tmpa,&tmpb);
if (tmpa<0) typ=0;
else typ=1;
a[typ][tail[typ]]=tmpa;
b[typ][tail[typ]]=tmpb;
tail[typ]++;
}
//for (int i=0;i<2;i++)
//for (int j=0;j<tail[i];j++) printf("%lld %d\n",a[i][j],b[i][j]);
l=0;
r=1.0*(-a[0][0]+a[1][0])/(b[0][0]+b[1][0]);
printf("%.9lf\n",r);
for (int i=0;i<50;i++){
double mid=(l+r)/2;
if (check(mid)) r=mid;
else l=mid;
}
printf("%d %d %.9lf %.9lf\n",tail[0],tail[1],l,r);
printf("%.9lf\n",(l+r)/2*v);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 10036kb
input:
3 4 9 10 2 -7 2 -6 1 7 1 2 8 -1 7 1 6 2 3 -1000000000000 1 1000000000000 1
output:
4.250000000 2 2 4.250000000 4.250000000 38.250000000 0.153846154 1 1 0.153846154 0.153846154 1.230769231 1000000000000.000000000 1 1 999999999999.999145508 1000000000000.000000000 2999999999999.998535156
result:
wrong answer 1st numbers differ - expected: '38.2500000', found: '4.2500000', error = '0.8888889'