QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#728185 | #5978. Runaway Quail | DengDuck | 0 | 2499ms | 6900kb | C++14 | 1.3kb | 2024-11-09 14:44:11 | 2024-11-09 14:44:13 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define LF long double
const int N=505;
const LF E=1e-12;
const LF Inf=1e18;
int n,m1,m2,C,P[N],V[N];
LF F[N][N];
struct Node{int P,v;}A[N],B[N];
inline LF Pos(Node A,LF y){return A.P+A.v*y;}
inline LF Cal(Node A,LF y){return Pos(A,y)*1.0/(C-A.v);}
inline LF Work()
{
scanf("%d%d",&C,&n);
for(int i=1;i<=n;i++)scanf("%d",&P[i]);
for(int i=1;i<=n;i++)scanf("%d",&V[i]);
m1=0,m2=0;
for(int i=1;i<=n;i++)
{
if(P[i]>0)A[++m1]={P[i],V[i]};
else B[++m2]={-P[i],V[i]};
}
sort(A+1,A+m1+1,[](Node X,Node Y){
if(X.v!=Y.v)return X.v<Y.v;
return X.P<Y.P;
});
sort(B+1,B+m2+1,[](Node X,Node Y){
if(X.v!=Y.v)return X.v<Y.v;
return X.P<Y.P;
});
for(int i=0;i<=m1;i++)fill(F[i],F[i]+m1+1,Inf);
F[m1][m2]=0;
for(int i=m1;i>=0;i--)
for(int j=m2;j>=0;j--)
{
LF T=F[i][j],P1=Pos(A[i],T),P2=Pos(B[j],T),Mx=0;
for(int k=i;k>=1;k--)
{
if(Pos(A[k],T)>=P1-E)Mx=max(Mx,Cal(A[k],T));
LF K=T+Mx*2;
if(k==1&&j==0)K-=Mx;
F[k-1][j]=min(F[k-1][j],K);
}
Mx=0;
for(int k=i;k>=1;k--)
{
if(Pos(B[k],T)>=P2-E)Mx=max(Mx,Cal(B[k],T));
LF K=T+Mx*2;
if(k==1&&i==0)K-=Mx;
F[i][k-1]=min(F[i][k-1],K);
}
}
return F[0][0];
}
int main()
{
int T;scanf("%d",&T);
for(int i=1;i<=T;i++)printf("Case #%d: %.9Lf\n",i,Work());
}
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: 3984kb
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: 1000000000000000000.000000000 Case #2: 5.000000000 Case #3: 1605.486238532 Case #4: 6772.589771491 Case #5: 58605.299748111 Case #6: 1245.667398463 Case #7: 36644.906397809 Case #8: 44320.278915520 Case #9: 236999.025224434 Case #10: 58531.582389937 Case #11: 14437.004123591 Case #12: 41134...
result:
wrong answer read 1000000000000000000.000000000000 but expected 3.000000000000 (test case 1)
Subtask #2:
score: 0
Wrong Answer
Test #2:
score: 0
Wrong Answer
time: 2499ms
memory: 6900kb
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: 1000000000000000000.000000000 Case #2: 5.000000000 Case #3: 635.419678715 Case #4: 42649.508513753 Case #5: 98523.574166011 Case #6: 65034.489979960 Case #7: 31948.342885561 Case #8: 23671.693967835 Case #9: 58384.702634881 Case #10: 50355.213362208 Case #11: 168599.881744040 Case #12: 2162...
result:
wrong answer read 1000000000000000000.000000000000 but expected 3.000000000000 (test case 1)