QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#607000 | #5505. Great Chase | hzy99999# | WA | 480ms | 3964kb | C++20 | 1.1kb | 2024-10-03 13:32:58 | 2024-10-03 13:32:59 |
Judging History
answer
#include<iostream>
#include<cmath>
using namespace std;
typedef long long LL;
typedef long double ldb;
const int N=400005;
const ldb eps=1e-9l;
int n,v;
LL standar;
struct People {
LL s;
int v;
} A[N];
bool check(ldb t) {
ldb lowS=-1e13,uprS=1e13;
for(int i=1; i<=n; i++) {
if(A[i].s<0) {
if(A[i].v*t+A[i].s>lowS) lowS=A[i].v*t+A[i].s;
} else {
if(A[i].s-A[i].v*t<uprS) uprS=A[i].s-A[i].v*t;
}
}
return uprS<=lowS;
}
void solve() {
scanf("%d%d",&n,&v);
ldb mnt=1e13;
for(int i=1; i<=n; i++) {
scanf("%lld%d",&A[i].s,&A[i].v);
mnt=min(mnt,fabs(1.0l*A[i].s)/A[i].v);
}
ldb L=0,R=1e14,ans=0,lastL=0,lastR=0;
while(R-L>eps) {
ldb mid=(L+R)/2;
if(check(mid)) {
ans=mid;
if(R-mid<eps)break;
R=mid;
}
else {
if(mid-L<eps)break;
L=mid;
}
}
printf("%.8Lf\n",ans*v);
}
int main() {
int T;scanf("%d",&T);
while(T--) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3964kb
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 3000000000000.00000000
result:
ok 3 numbers
Test #2:
score: -100
Wrong Answer
time: 480ms
memory: 3916kb
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.34956951 16414958969.72767376 5202715639.83532787 321977234.15656195 45384199210.22202234 183885744.76924838 1708925225.23109103 89786664971.55823130 13924365606.28778480 412975327.55556052 965508404.51237440 4703493416.28858578 352961619.38138072 5575125771.79895786 341191687.00022627 ...
result:
wrong answer 4566th numbers differ - expected: '1.0000010', found: '1.0005577', error = '0.0005567'