QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#357501#3994. Easy JumpChrysanthBlossomWA 0ms3932kbC++141.7kb2024-03-18 21:58:372024-03-18 21:58:37

Judging History

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

  • [2024-03-18 21:58:37]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3932kb
  • [2024-03-18 21:58:37]
  • 提交

answer

#include<bits/stdc++.h>
#define ri register int
#define ll long long
#define ld long double
using namespace std;
const int maxn=1e3+7;
ld f[maxn][10][10];
int n,S,H;
int k;
int T1,T2;
ld p[maxn];
bool hv[maxn];
const ld inf=1e16;
void solve(){
	for(ri i=n;i;i--){
		for(ri j=1;j<H;j++){
			for(ri k=0;k<=S;k++){
				if(j==1){
					f[i][j][k]=(1+p[i]*f[i+1][j][k]+(1-p[i])*T2)/p[i];
				}
				else{
					f[i][j][k]=(1+p[i]*f[i+1][j][k]+(1-p[i])*f[i][j-1][k]);
				}
			}
		}
	}
	cout<<f[1][H-1][S]<<endl;
	exit(0);
}
signed main(){
	ios::sync_with_stdio(0);
	cin>>n>>H>>S;
	for(ri i=1;i<=n;i++){
		cin>>p[i];
		p[i]/=100;
	}
	cin>>k;
	for(ri i=1;i<=k;i++){
		int t;cin>>t;
		hv[t]=1;
	}
	cin>>T1>>T2;
	for(ri i=1;i<=n;i++){
		for(ri j=0;j<=H;j++){
			for(ri k=0;k<=S;k++){
				f[i][j][k]=inf;
			}
		}
	}
	if(T1>=T2)solve();
	for(ri i=n;i;i--){
		if(!S||!hv[i]){
			for(ri j=1;j<H;j++){
				for(ri k=0;k<=S;k++){
					if(j>=2){
						f[i][j][k]=(1+p[i]*f[i+1][j][k]+(1-p[i])*f[i][j-1][k]);
					}
					else if(k>=1){
						f[i][j][k]=(1+p[i]*f[i+1][j][k]+(1-p[i])*(T1+f[i][j][k-1]));
					}
					else{
						f[i][j][k]=(1+p[i]*f[i+1][j][k]+(1-p[i])*T2)/p[i];
					}
				}
			}
		}
		else{
			for(ri j=1;j<H;j++){
				f[i][j][S]=(1+f[i+1][j][S]*p[i]+(1-p[i])*T1)/p[i];
				for(ri now=1;now<j;now++){
					f[i][now][S]=min(f[i][now][S],f[i][j][S]+T1*(j-now));
				}
			}
		}
	}
//	for(ri i=1;i<=n;i++){
//		for(ri j=1;j<H;j++){
//			for(ri k=0;k<=S;k++){
//				cout<<f[i][j][k]<<' ';
//			} cout<<endl;
//		}
//		cout<<"------------------------------\n";
//	}
	cout<<f[1][H-1][S];
	return 0;
}
/*
1 6 4
75
0
64 6
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3876kb

input:

1 2 0
50
0
1 2

output:

4

result:

ok found '4.0000000', expected '4.0000000', error '0.0000000'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3880kb

input:

2 3 1
50 50
1 1
1 3

output:

6

result:

ok found '6.0000000', expected '6.0000000', error '0.0000000'

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3932kb

input:

1 6 4
75
0
64 6

output:

1.34115

result:

wrong answer 1st numbers differ - expected: '1.3411458', found: '1.3411500', error = '0.0000031'