QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#673986 | #8022. Walker | ty | TL | 114ms | 60264kb | Java11 | 1.3kb | 2024-10-25 12:54:31 | 2024-10-25 12:54:31 |
Judging History
answer
import java.util.Scanner;
public class Main {
public static double cal(double n,double x,double vx,double y,double vy,double mid) {
double l1 = Math.min((mid-x + mid)/vx,(x*2 + mid-x)/vx);
double l2 = Math.min((y-mid + n - mid)/vy,(n-y + n-mid)/vy);
return Math.max(l1,l2);
}
public static void main(String[] arg) {
Scanner input = new Scanner(System.in);
int caset = input.nextInt();
double eps = 0.000001;
while(caset > 0) {
caset--;
double n = input.nextDouble();
double x = input.nextDouble();
double vx = input.nextDouble();
double y = input.nextDouble();
double vy = input.nextDouble();
if(x > y) {
double c = x;
double vc = vx;
x = y;
vx = vy;
y = c;
vy = vc;
}
double t1 = Math.max((n-x)/vx,y/vy);
double t2 = (x + n-y + n)/(vx + vy);
double t3 = Math.min((Math.min(x,n-x) + n)/vx,(Math.min(y,n-y) + n)/vy);
double l = x;
double r = y;
while(r - l > eps) {
double mid = (l+r)/2;
if(cal(n,x,vx,y,vy,mid-eps) < cal(n,x,vx,y,vy,mid+eps)) r = mid;
else l = mid;
}
double mid = (l+r)/2;
double ans = Math.min(t1,t2);
ans = Math.min(ans,t3);
ans = Math.min(ans,cal(n,x,vx,y,vy,mid));
System.out.printf("%.5f\n",ans);
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 110ms
memory: 58216kb
input:
2 10000.0 1.0 0.001 9999.0 0.001 4306.063 4079.874 0.607 1033.423 0.847
output:
5001000.00000 3827.83700
result:
ok 2 numbers
Test #2:
score: 0
Accepted
time: 100ms
memory: 54040kb
input:
1 10.0 1.0 10.0 9.0 0.1
output:
1.10000
result:
ok found '1.1000000', expected '1.1000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 106ms
memory: 53740kb
input:
1 10.0 8.0 10.0 9.0 0.1
output:
1.20000
result:
ok found '1.2000000', expected '1.2000000', error '0.0000000'
Test #4:
score: 0
Accepted
time: 88ms
memory: 55468kb
input:
1 10.0 8.0 0.1 9.0 10
output:
1.10000
result:
ok found '1.1000000', expected '1.1000000', error '0.0000000'
Test #5:
score: 0
Accepted
time: 104ms
memory: 56300kb
input:
1 10.0 2.0 0.1 3.0 10
output:
1.30000
result:
ok found '1.3000000', expected '1.3000000', error '0.0000000'
Test #6:
score: 0
Accepted
time: 111ms
memory: 55136kb
input:
1 10.0 9.0 0.1 8.0 10.0
output:
1.20000
result:
ok found '1.2000000', expected '1.2000000', error '0.0000000'
Test #7:
score: 0
Accepted
time: 111ms
memory: 54768kb
input:
1 10.0 4.0 0.1 6.0 0.1
output:
60.00000
result:
ok found '60.0000000', expected '60.0000000', error '0.0000000'
Test #8:
score: 0
Accepted
time: 112ms
memory: 54948kb
input:
1 10.0 4.5 0.1 6.0 0.1
output:
57.50000
result:
ok found '57.5000000', expected '57.5000000', error '0.0000000'
Test #9:
score: 0
Accepted
time: 108ms
memory: 54312kb
input:
1 10.0 1.0 1.0 8.0 1.0
output:
6.50000
result:
ok found '6.5000000', expected '6.5000000', error '0.0000000'
Test #10:
score: 0
Accepted
time: 105ms
memory: 60264kb
input:
1 10.0 3.0 2.0 7.0 1.0
output:
4.60000
result:
ok found '4.6000000', expected '4.6000000', error '0.0000000'
Test #11:
score: 0
Accepted
time: 110ms
memory: 54176kb
input:
1 10.0 6.0 2.0 7.0 1.0
output:
3.66667
result:
ok found '3.6666700', expected '3.6666667', error '0.0000009'
Test #12:
score: 0
Accepted
time: 110ms
memory: 56412kb
input:
1 10.0 1.0 1.0 9.0 1.0
output:
6.00000
result:
ok found '6.0000000', expected '6.0000000', error '0.0000000'
Test #13:
score: 0
Accepted
time: 114ms
memory: 58392kb
input:
1 10000.0 1.0 0.001 1.0 0.001
output:
9999000.00000
result:
ok found '9999000.0000000', expected '9999000.0000000', error '0.0000000'
Test #14:
score: 0
Accepted
time: 95ms
memory: 57876kb
input:
1 10.0 5.0 1.0 5.0 1.5
output:
5.00000
result:
ok found '5.0000000', expected '5.0000000', error '0.0000000'
Test #15:
score: -100
Time Limit Exceeded
input:
10000 4306.063 4079.874 0.607 1033.423 0.847 8967.336 8026.500 0.398 283.019 0.876 9568.147 4481.616 0.405 800.114 0.684 9867.264 6184.040 0.312 9853.164 0.641 3344.364 730.612 0.539 1305.868 0.947 9336.180 3672.113 0.773 432.686 0.312 1468.243 59.762 0.840 1438.446 0.827 1355.133 1096.314 0.373 109...
output:
3827.83700 7999.36499 12559.33580 15371.55070 2637.69852 9931.04152 934.49430 2939.17962 5754.03289 2847.42716 10975.32363 2180.27861 23747.04545 6278.10356 872.39771 10734.39564 1005.07703 20225.16309 9878.00995 22899.25927 12241.08593 33365.47620 3153.05873 11691.59763 20162.71115 6052.69672 5846....