QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#646246#8022. Walkerkans2298WA 15ms3980kbC++172.2kb2024-10-16 21:54:092024-10-16 21:54:12

Judging History

你现在查看的是最新测评结果

  • [2024-10-16 21:54:12]
  • 评测
  • 测评结果:WA
  • 用时:15ms
  • 内存:3980kb
  • [2024-10-16 21:54:09]
  • 提交

answer

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;
int main()
{
     int ti,t;
     //freopen("input.in","r",stdin);
     ios::sync_with_stdio(false);
     cin.tie(nullptr);
     cin>>t;
     for (ti=1;ti<=t;++ti)
     {
     long double n_,p1_,p2_,n1_,n2_;
     cin>>n_>>p1_>>n1_>>p2_>>n2_;
     long double n=n_*1000,p1=p1_*1000,p2=p2_*1000,n1=n1_*1000,n2=n2_*1000;
     //cout<<n<<" "<<p1<<" "<<p2<<" "<<n1<<" "<<n2<<"\n";
     if (not (p1<=p2))
          {
          swap(p1,p2);
          swap(n1,n2);
          }
     long double ans1=1e9;
     ans1=min(ans1,1.0*(n+min(p1,n-p1))/n1);
     ans1=min(ans1,1.0*(n+min(p2,n-p2))/n2);
     auto check1 = [](long double n, long double p1, long double p2, long double n1, long double n2)
     {
          long double d;
          d = 1.0 * (2 * n * n1 - p2 * n1 + n2 * p1) / (2 * n2 + n1);
          if (d - p1 <= p1 && n - p2 <= p2 - d)
          {
               return d;
          }
          d = 1.0 * (n * n1 + p2 * n1 + n2 * p1) / (2 * (n1 + n2));
          if (d - p1 <= p1 && p2 - d <= n - p2)
          {
               return d;
          }
          d = 1.0 * (2 * n * n1 - p2 * n1 - n2 * p1) / (n1 + n2);
          if (p1 <= d - p1 && n - p2 <= p2 - d)
          {
               return d;
          }
          d = 1.0 * (n * n1 + p2 * n1 - n2 * p1) / (2 * n1 + n2);
          if (p1 <= d - p1 && p2 - d <= n - p2)
          {
               return d;
          }
          return (long double)(-1.0);
     };
     auto door=check1(n,p1,p2,n1,n2);
     long double T=1e9;
     if (p1==p2)
          {
          long double t1=max(1.0*p1/n1,1.0*(n-p1)/n2);
          long double t2=max(1.0*p1/n2,1.0*(n-p1)/n1);
          T=min(T,min(t1,t2));
          }
     if (door>0 && p1<=door && door<=p2) T=min(T,(door+min(door-p1,(long double)(p1)))/n1);
     door=p1;
     long double tA=1.0*p1/n1,tB=1.0*(n-p1+min(n-p2,p2-p1))/n2;
     T=min(T,max(tA,tB));
     door=p2;
     tA=1.0*(p2+min(p1,p2-p1))/n1,tB=1.0*(n-p2)/n2;
     T=min(T,max(tA,tB));
     cout<<fixed<<setprecision(8)<<min((long double)(ans1),T)<<"\n";
     }
     return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3980kb

input:

2
10000.0 1.0 0.001 9999.0 0.001
4306.063 4079.874 0.607 1033.423 0.847

output:

5001000.00000000
3827.83700138

result:

ok 2 numbers

Test #2:

score: 0
Accepted
time: 0ms
memory: 3912kb

input:

1
10.0 1.0 10.0 9.0 0.1

output:

1.10000000

result:

ok found '1.1000000', expected '1.1000000', error '0.0000000'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

1
10.0 8.0 10.0 9.0 0.1

output:

1.20000000

result:

ok found '1.2000000', expected '1.2000000', error '0.0000000'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

1
10.0 8.0 0.1 9.0 10

output:

1.10000000

result:

ok found '1.1000000', expected '1.1000000', error '0.0000000'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3916kb

input:

1
10.0 2.0 0.1 3.0 10

output:

1.30000000

result:

ok found '1.3000000', expected '1.3000000', error '0.0000000'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3924kb

input:

1
10.0 9.0 0.1 8.0 10.0

output:

1.20000000

result:

ok found '1.2000000', expected '1.2000000', error '0.0000000'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

1
10.0 4.0 0.1 6.0 0.1

output:

60.00000000

result:

ok found '60.0000000', expected '60.0000000', error '0.0000000'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3924kb

input:

1
10.0 4.5 0.1 6.0 0.1

output:

57.50000000

result:

ok found '57.5000000', expected '57.5000000', error '0.0000000'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3724kb

input:

1
10.0 1.0 1.0 8.0 1.0

output:

6.50000000

result:

ok found '6.5000000', expected '6.5000000', error '0.0000000'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3860kb

input:

1
10.0 3.0 2.0 7.0 1.0

output:

4.60000000

result:

ok found '4.6000000', expected '4.6000000', error '0.0000000'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3912kb

input:

1
10.0 6.0 2.0 7.0 1.0

output:

3.66666667

result:

ok found '3.6666667', expected '3.6666667', error '0.0000000'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3872kb

input:

1
10.0 1.0 1.0 9.0 1.0

output:

6.00000000

result:

ok found '6.0000000', expected '6.0000000', error '0.0000000'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3856kb

input:

1
10000.0 1.0 0.001 1.0 0.001

output:

9999000.00000000

result:

ok found '9999000.0000000', expected '9999000.0000000', error '0.0000000'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3976kb

input:

1
10.0 5.0 1.0 5.0 1.5

output:

5.00000000

result:

ok found '5.0000000', expected '5.0000000', error '0.0000000'

Test #15:

score: -100
Wrong Answer
time: 15ms
memory: 3880kb

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.83700138
7999.36499215
12559.33580247
15415.54446178
2637.69851952
9931.04151754
934.49430114
4326.94906166
5754.03288987
2847.42715700
10975.32362822
2902.17910448
24531.53636364
6278.10355487
1030.00000000
10734.39564428
1005.07702889
24249.74678112
9878.00994575
22899.25925926
12409.89777778...

result:

wrong answer 4th numbers differ - expected: '15371.5507020', found: '15415.5444618', error = '0.0028620'