QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#140205 | #5505. Great Chase | PhantomThreshold# | WA | 514ms | 3836kb | C++20 | 728b | 2023-08-15 13:58:01 | 2023-08-15 13:58:03 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
int T;
cin>>T;
while(T--)
{
int n,V;
cin>>n>>V;
vector<long long> p(n+5),v(n+5);
for(int i=1;i<=n;i++)
{
cin>>p[i]>>v[i];
}
auto check=[&](long double t)
{
long double maxx=-1e18,minn=1e18;
for(int i=1;i<=n;i++)
{
if(p[i]>0)minn=min(minn,p[i]-v[i]*t);
else maxx=max(maxx,p[i]+v[i]*t);
}
// cerr<<"check "<<t<<' '<<minn<<' '<<maxx<<endl;
return minn<=maxx;
};
long double l=0,r=1e12;
for(int tt=1;tt<=70;tt++)
{
double mid=(l+r)/2;
if(check(mid))r=mid;
else l=mid;
}
cout<<fixed<<setprecision(8)<<l*V<<endl;
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3836kb
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:
38.25000000 1.23076923 2999999999999.99999976
result:
ok 3 numbers
Test #2:
score: -100
Wrong Answer
time: 514ms
memory: 3820kb
input:
10000 200 997007 405524182320 754760 686939601648 419804 687047488212 715566 1446157132 4594 -670522037 4673 763634629282 253755 424307411732 275041 1582708381 8473 -667425982 4622 -522841486 1427 702430907988 460271 1405423646 1060 1497754648 6227 883363410675 723547 56899800372 46435 -810216390 64...
output:
145405766328.34888336 16414958969.72717414 5202715639.83509424 321977234.15612710 45384199210.22112295 183885744.76922955 1708925225.22985302 89786664971.55788843 13924365606.28736612 412975327.55546405 965508404.51180228 4703493416.28810820 352961619.38090443 5575125771.79811169 341191686.99932121 ...
result:
wrong answer 4566th numbers differ - expected: '1.0000010', found: '0.9994989', error = '0.0005021'