QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#733617#5978. Runaway QuailDengDuck8 981ms5440kbC++141.2kb2024-11-10 20:09:482024-11-10 20:09:49

Judging History

你现在查看的是最新测评结果

  • [2024-11-10 20:09:49]
  • 评测
  • 测评结果:8
  • 用时:981ms
  • 内存:5440kb
  • [2024-11-10 20:09:48]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define LF double
const int N=505;
const LF Inf=1e10;
int n,m1,m2,C,P[N],V[N];
LF F[N][N];
struct Node
{
	int P,v;
	bool operator<(const Node&A)const
	{
		if(v!=A.v)return v<A.v;
		return P<A.P;
	}
}A[N],B[N];
LF Pos(Node A,LF y){return A.P+A.v*y;}
LF Cal(Node A,LF y){return Pos(A,y)/(C-A.v);}
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);
	sort(B+1,B+m2+1);
	for(int i=0;i<=m1;i++)fill(F[i],F[i]+m2+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--)
		{
			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=j;k>=1;k--)
		{
			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());
}

详细

Subtask #1:

score: 8
Accepted

Test #1:

score: 8
Accepted
time: 1ms
memory: 4024kb

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.000000000
Case #2: 5.000000000
Case #3: 51133.937500000
Case #4: 429262.396142110
Case #5: 129368.012279597
Case #6: 7801.832031250
Case #7: 66656.812500000
Case #8: 607220.690423515
Case #9: 5725896.876344086
Case #10: 129205.285220126
Case #11: 64298.000000000
Case #12: 610881.705159705...

result:

ok correct! (50 test cases)

Subtask #2:

score: 0
Wrong Answer

Test #2:

score: 0
Wrong Answer
time: 981ms
memory: 5440kb

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.000000000
Case #2: 5.000000000
Case #3: 205911250.088888884
Case #4: 36298.000000000
Case #5: 186002.250000000
Case #6: 13741948.500000000
Case #7: 109001.125000000
Case #8: 38656.812500000
Case #9: 128881.056148055
Case #10: 8069407.987096774
Case #11: 128881.056148055
Case #12: 124955.3...

result:

wrong answer read 10000000000.000000000000 but expected 17827058945.000000000000 (test case 29)