QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#728711 | #5978. Runaway Quail | little_pinkpig | 0 | 2853ms | 6744kb | C++14 | 2.2kb | 2024-11-09 15:44:51 | 2024-11-09 15:44:52 |
Judging History
answer
#include<bits/stdc++.h>
#define MAXN (505)
#define ll long long
#define db double
#define ldb long double
#define pi pair<int,int>
#define fi first
#define se second
using namespace std;
const int lim=500000;
const ldb eps=1e-12,inf=1e18;
template<typename type>
void read(type &x)
{
bool f=0;char ch=0;x=0;
while(ch<'0'||ch>'9'){f|=!(ch^'-');ch=getchar();}
while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
x=f?-x:x;
}
template<typename type,typename... Args>
void read(type &x,Args &... args)
{
read(x);
read(args...);
}
int test,vt,n,tota,totb,cas;
int pos[MAXN],v[MAXN];
ldb f[MAXN][MAXN];
struct node{
int pos,vc;
inline bool operator<(node rsh){return (vc^rsh.vc)?(vc<rsh.vc):(pos<rsh.pos);}
}a[MAXN],b[MAXN];
inline ldb getpos(node x,ldb tim){return x.pos+tim*x.vc;}
inline ldb gettim(node x,ldb tim){return getpos(x,tim)/(vt-x.vc);}
void solve()
{
read(vt,n);
for(int i=1;i<=n;i++) read(pos[i]);
for(int i=1;i<=n;i++) read(v[i]);
tota=totb=0;
for(int i=1;i<=n;i++)
{
if(pos[i]<0) a[++tota]={-pos[i],v[i]};
else b[++totb]={pos[i],v[i]};
}
sort(a+1,a+tota+1),sort(b+1,b+totb+1);
for(int i=0;i<=tota;i++) fill(f[i],f[i]+totb+1,inf);
f[tota][totb]=0;
for(int i=tota;~i;i--)
{
for(int j=tota;~j;j--)
{
ldb t=f[i][j],pos1=getpos(a[i],t),pos2=getpos(b[j],t),mx=0;
for(int k=i;k;k--)
{
if(pos1-getpos(a[k],t)<=eps) mx=max(mx,gettim(a[k],t));
ldb ntim=t+mx*2;
if(k==1&&!j) ntim-=mx;
f[k-1][j]=min(f[k-1][j],ntim);
}
mx=0;
for(int k=j;k;k--)
{
if(pos2-getpos(b[k],t)<=eps) mx=max(mx,gettim(b[k],t));
ldb ntim=t+mx*2;
if(k==1&&!i) ntim-=mx;
f[i][k-1]=min(f[i][k-1],ntim);
}
}
}
printf("Case #%d: %.10Lf\n",++cas,f[0][0]);
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("tiii.in","r",stdin);
freopen("tiii.out","w",stdout);
#endif
read(test);
for(int i=1;i<=test;i++) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3996kb
input:
50 4 3 -3 -6 -9 3 2 1 2 2 1 -1 1 1 1000 25 769234 -5735820 -524288 -5403090 -6429140 1574982 1 -9733628 -1407481 4093041 4117720 -3193501 -9765195 -3069520 1122216 -5799108 131072 -8482066 -256 -8021159 -8958386 -7027036 5370579 -3602534 -6834567 425 102 744 155 339 19 999 19 159 198 51 304 369 601 ...
output:
Case #1: 0.0000000000 Case #2: 5.0000000000 Case #3: 5934.3414364641 Case #4: 32544.3817567568 Case #5: 1000000000000000000.0000000000 Case #6: 7801.8320312500 Case #7: 1000000000000000000.0000000000 Case #8: 1000000000000000000.0000000000 Case #9: 1000000000000000000.0000000000 Case #10: 1000000000...
result:
wrong answer read 0.000000000000 but expected 3.000000000000 (test case 1)
Subtask #2:
score: 0
Wrong Answer
Test #2:
score: 0
Wrong Answer
time: 2853ms
memory: 6744kb
input:
50 4 3 -3 -6 -9 3 2 1 2 2 1 -1 1 1 1000 500 -9650379 9806301 -6495789 -1283284 5022779 4725553 9364178 -8123302 -9609729 7847458 -142364 6983908 8147008 -3186924 7339254 -8737645 8757174 7887319 3609962 5780915 -1752801 -1657946 -9511339 5113995 -7887160 -6093170 260267 -3837106 -356098 6676924 6210...
output:
Case #1: 0.0000000000 Case #2: 5.0000000000 Case #3: 1539502.1666666667 Case #4: 1000000000000000000.0000000000 Case #5: 1000000000000000000.0000000000 Case #6: 13741948.5000000000 Case #7: 86856.5243581914 Case #8: 1000000000000000000.0000000000 Case #9: 1000000000000000000.0000000000 Case #10: 806...
result:
wrong answer read 0.000000000000 but expected 3.000000000000 (test case 1)