QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#471345#8022. WalkerlonlynessWA 0ms3804kbC++231.8kb2024-07-10 20:41:222024-07-10 20:41:23

Judging History

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

  • [2024-07-10 20:41:23]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3804kb
  • [2024-07-10 20:41:22]
  • 提交

answer

#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<cmath>
using namespace std;
#define int long long 
#define endl "\n"
const int N = 2e5+10;
const double esp=1e-8;
typedef pair<int,int> PII;
double n,q1,v1,q2,v2;
bool check(double mid)
{
    bool flag1=1,flag2=1;
    double x2= v2*mid;
    double cnt2=0;
    double cnt1=0;
    if(x2<n-q2)flag2=0;
    else {
        cnt2=max((double)(x2+q2-n)/2.0,(double)(x2-(n-q2)*2.0));
    }
    double x1=v1*mid;
    if(x1<q1)flag1=0;
    else {
        cnt1=max((double)(x1-q1)/2.0,(double)x1-q1*2);
    }
    if(!flag1)
    {
        if(!flag2)return false;
        else {
            if(cnt2>=q2)return true;
            else return false;
        }
    }
    else if(!flag2){
        if(!flag1)return false;
        else {
            if(cnt1>=n-q1)return true;
            else return false;
        }
    }
    else {
        if(cnt1+cnt2>=q2-q1)return true;
        else return false;
    }
}
void solve()  
{
    cin>>n>>q1>>v1>>q2>>v2;
    // cout<<n<<' '<<q1<<' '<<v1<<' '<<q2<<' '<<v2<<endl;
    if(q1>q2){
        swap(q1,q2);
        swap(v1,v2);
    }
    double l = 0,r= 1e7+10;
    int cnt = 0;
    // check(5002000.2);
    while(r-l>esp)
    {
        // cnt++;
        // if(cnt>100)break;
        double mid = (double)(r+l)/2;
        if(check(mid))r= mid;
        else l = mid;
        // printf("%.8f %.8f %.8f\n",r,l,mid);
        
    }
    double cnt1=max((n-q1)/v1,q2/v2);
    double cnt2=(n+min(q1,n-q1))/v1;
    double cnt3=(n+min(q2,n-q2))/v2;
    l = min(cnt1,min(cnt2,cnt3));
    printf("%.8f\n",l);
}
signed  main()
{
    // ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
  int t=1;
  cin>>t;
  while(t--)
  {
      solve();
  }
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3804kb

input:

2
10000.0 1.0 0.001 9999.0 0.001
4306.063 4079.874 0.607 1033.423 0.847

output:

9999000.00000000
6303.99763872

result:

wrong answer 1st numbers differ - expected: '5001000.0000000', found: '9999000.0000000', error = '0.9994001'