QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#379119 | #8022. Walker | comeintocalm# | WA | 0ms | 3956kb | C++17 | 1.6kb | 2024-04-06 16:16:39 | 2024-04-06 16:16:40 |
Judging History
answer
#include <bits/stdc++.h>
#define LL long long
#define db long double
using namespace std;
const db eps = 1e-13;
int T;
db n, p[2], v[2];
int chk (db t) {
db l1 = t * v[0], l2 = t * v[1];
db p1 = 0, p2 = n;
if (l1 < p[0]) p1 = 0;
else if (l1 <= p[0] * 2) p1 = p[0];
else if (l1 <= p[0] * 3) p1 = (l1 - p[0]) / 2 + p[0];
else p1 = l1 - p[0];
if (l2 < n - p[1]) p2 = n;
else if (l2 <= (n - p[1]) * 2) p2 = p[1];
else if (l2 <= (n - p[1]) * 3) p2 = p[1] - (l2 - (n - p[1])) / 2;
else p2 = n - (l2 - (n - p[1]));
return p2 <= p1;
}
int main() {
int i,j,k;
scanf ("%d", &T);
while (T--) {
scanf ("%Lf%Lf%Lf%Lf%Lf", &n, &p[0], &v[0], &p[1], &v[1]);
if (p[0] > p[1]) swap (p[0], p[1]), swap (v[0], v[1]);
db L = 0, R = 1e18;
int cnt = 300;
while (cnt--) {
db mid = (L + R) / 2.0;
if (chk (mid)) R = mid;
else L = mid;
}
printf ("%.15Lf\n", L);
/*
db ans = min (calc (0, 0, n), calc (1, 0, n));
//printf ("%.15Lf\n", ((db) 1000) / ((db)0.001));
//printf ("%.15Lf\n", ans);
//return 0;
//ans = min (ans, max (0, 0, p[1]))
//cout << n << endl;
//cout << calc (0, 0, n) << endl;
db L = p[0], R = p[1];
int cnt = 300;
while (cnt--) {
db fm = (R - L) / ((db) 3.0), m1 = L + fm, m2 = R - fm;
db a1 = max (calc (0, 0, m1), calc (1, m1, n));
db a2 = max (calc (0, 0, m2), calc (1, m2, n));
ans = min (ans, a1);
ans = min (ans, a2);
if (a1 < a2) R = m2;
else L = m1;
}
ans = min (ans, max (calc (0, 0, L), calc (1, L, n)));
printf ("%.15Lf\n", ans);
*/
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3928kb
input:
2 10000.0 1.0 0.001 9999.0 0.001 4306.063 4079.874 0.607 1033.423 0.847
output:
5000999.999999999999545 3827.837001375515818
result:
ok 2 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3956kb
input:
1 10.0 1.0 10.0 9.0 0.1
output:
1.100000000000000
result:
ok found '1.1000000', expected '1.1000000', error '0.0000000'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3888kb
input:
1 10.0 8.0 10.0 9.0 0.1
output:
1.600000000000000
result:
wrong answer 1st numbers differ - expected: '1.2000000', found: '1.6000000', error = '0.3333333'