QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#728739 | #5978. Runaway Quail | little_pinkpig | 23 ✓ | 2702ms | 6620kb | C++14 | 2.2kb | 2024-11-09 15:48:55 | 2024-11-09 15:48:56 |
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=totb;~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(".in","r",stdin);
freopen(".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: 8
Accepted
Test #1:
score: 8
Accepted
time: 1ms
memory: 4048kb
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: 3.0000000000 Case #2: 5.0000000000 Case #3: 51133.9375000000 Case #4: 429262.3961421099 Case #5: 129368.0122795970 Case #6: 7801.8320312500 Case #7: 66656.8125000000 Case #8: 607220.6904235145 Case #9: 5725896.8763440860 Case #10: 129205.2852201258 Case #11: 64298.0000000000 Case #12: 61088...
result:
ok correct! (50 test cases)
Subtask #2:
score: 15
Accepted
Test #2:
score: 15
Accepted
time: 2702ms
memory: 6620kb
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: 3.0000000000 Case #2: 5.0000000000 Case #3: 205911250.0888888889 Case #4: 36298.0000000000 Case #5: 186002.2500000000 Case #6: 13741948.5000000000 Case #7: 109001.1250000000 Case #8: 38656.8125000000 Case #9: 128881.0561480552 Case #10: 8069407.9870967742 Case #11: 128881.0561480552 Case #1...
result:
ok correct! (50 test cases)
Extra Test:
score: 0
Extra Test Passed