QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#239743 | #5505. Great Chase | KLPP# | WA | 0ms | 3880kb | C++20 | 1.2kb | 2023-11-04 22:56:10 | 2023-11-04 22:56:10 |
Judging History
answer
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int lld;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define trav(a,v) for(auto a:v)
#define all(x) begin(x),end(x)
void solve(){
int n;
long double v;
cin>>n>>v;
vector<array<long double,2>> a(n);
for(auto&[i,j]:a)cin>>i>>j;
int iters=200;
long double L=0;
long double R=1e12;
while(iters--){
long double mid=(L+R)/2;
bool leftDefined=false;
bool rightDefined=false;
long double posLeft;
long double posRight;
for(auto[x,y]:a){
if(x<0){
if(!leftDefined){
leftDefined=true;
posLeft=x+mid*y;
}
else posLeft=max(posLeft,x+mid*y);
}
else{
if(!rightDefined){
rightDefined=true;
posRight=x-mid*y;
}
else posRight=min(posRight,x-mid*y);
}
}
if(posLeft>posRight)R=mid;
else L=mid;
}
cout<<fixed<<(v*L)<<"\n";
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int tt=1;
cin>>tt;
while(tt--){
solve();
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3880kb
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.250000 1.230769 3000000000000.000000
result:
wrong answer 2nd numbers differ - expected: '1.2307692', found: '1.2307690', error = '0.0000002'