QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#768840#8022. Walkersurenjamts#WA 0ms3888kbC++201.6kb2024-11-21 14:47:302024-11-21 14:47:38

Judging History

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

  • [2024-11-21 14:47:38]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3888kb
  • [2024-11-21 14:47:30]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve(){
    double n,p1,v1,p2,v2;
    cin>>n>>p1>>v1>>p2>>v2;
    if(p1 > p2) swap(p1, p2), swap(v1, v2);


    auto check = [&](double mid){
           double l1 = mid * v1, l2 = mid * v2;
           if(l1 >= n + p1) return 1;
           if(l2 >= 2 * n - p2) return 1;


           if(l1 >= p1 && l2 >= (n - p2) * 2){
                 double x1 = (l1 - p1) / 2;
                 double x2 = (l2 - 2 * (n - p2));
                 if(p1 + x1 > p2 - x2) return 1;
           }
           if(l1 >= p1 * 2 && l2 >= (n - p2)){
                 double x1 = (l1 - p1 * 2);
                 double x2 = (l2 - (n - p2)) / 2;
                 if(p1 + x1 > p2 - x2) return 1;
           }
           if(l1 >= p1 * 2 && l2 >= (n - p2) * 2){
                 double x1 = (l1 - p1 * 2);
                 double x2 = (l2 - (n - p2) * 2);
                 if(p1 + x1 > p2 - x2) return 1;

           }
           if(l1 >= p1 && l2 >= (n - p2)){
                 double x1 = (l1 - p1) /2;
                 double x2 = (l2 - (n - p2)) / 2;
                 if(p1 + x1 > p2 - x2) return 1;
           }


           if(l1 >= p1 && l2 >= 2 * n - p1 - p2) return 1;
           if(l2 >= (n - p2) && l1 >= p1 * p2) return 1;

           if(l1 >= (n - p1) && l2 >= p2) return 1;
           return 0;
    };

    double l = 0, r = 1e9;
    for(int i = 0; i < 200; i++){
          double mid = (l + r)/2;
          if(check(mid)) r = mid;
          else l = mid;
    }

    cout << setprecision(18) << l << '\n';


}
signed main(){
    int t;
    cin>>t;
    while(t--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
10000.0 1.0 0.001 9999.0 0.001
4306.063 4079.874 0.607 1033.423 0.847

output:

5001000
3827.83700137551614

result:

ok 2 numbers

Test #2:

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

input:

1
10.0 1.0 10.0 9.0 0.1

output:

1.09999999999999987

result:

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

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3840kb

input:

1
10.0 8.0 10.0 9.0 0.1

output:

1.7999999999999996

result:

wrong answer 1st numbers differ - expected: '1.2000000', found: '1.8000000', error = '0.5000000'