QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#357976#3994. Easy JumpChrysanthBlossomWA 1ms4088kbC++142.0kb2024-03-19 16:00:422024-03-19 16:00:43

Judging History

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

  • [2024-03-19 16:00:43]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4088kb
  • [2024-03-19 16:00:42]
  • 提交

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<<fixed<<setprecision(10)<<f[1][H-1][S]<<endl;
	exit(0);
}
ld g[10][10];
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++){
				for(ri k=1;k<H;k++){
					g[j][k]=inf;
				}
			}
			for(ri j=1;j<H;j++){
				for(ri k=j;k<H;k++){
					if(k==j){
						g[k][j]=(1+p[i]*f[i+1][k][S]+(1-p[i])*T1)/p[i];
					}
					else{
						g[k][j]=(1+p[i]*f[i+1][k][S]+(1-p[i])*g[k-1][j]);
					}
				}
			}
			for(ri j=1;j<H;j++){
				for(ri k=1;k<=j;k++){
					f[i][j][S]=min(f[i][j][S],g[j][k]);
				}
			}
			for(ri j=H-2;j;j--){
				f[i][j][S]=min(f[i][j][S],f[i][j+1][S]+T1);
			}
		}
	}
//	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<<fixed<<setprecision(10)<<f[1][H-1][S];
	return 0;
}
/*
1 2 0
50
0
1 2
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1 2 0
50
0
1 2

output:

4.0000000000

result:

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

Test #2:

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

input:

2 3 1
50 50
1 1
1 3

output:

6.0000000000

result:

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

Test #3:

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

input:

1 6 4
75
0
64 6

output:

1.3411458333

result:

ok found '1.3411458', expected '1.3411458', error '0.0000000'

Test #4:

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

input:

1 5 1
61
1 1
15 43

output:

2.2082231967

result:

ok found '2.2082232', expected '2.2082232', error '0.0000000'

Test #5:

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

input:

10 9 3
12 65 76 33 17 20 89 16 4 63
3 2 4 8
73 21

output:

942.4148420128

result:

ok found '942.4148420', expected '942.4148420', error '0.0000000'

Test #6:

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

input:

10 6 0
26 6 29 76 92 46 8 4 91 44
1 4
17 6

output:

401.8668629820

result:

ok found '401.8668630', expected '401.8668630', error '0.0000000'

Test #7:

score: -100
Wrong Answer
time: 1ms
memory: 4088kb

input:

100 3 5
85 59 20 75 58 42 79 95 22 15 95 81 69 73 45 42 99 93 58 8 18 34 88 14 23 37 87 16 96 17 40 58 32 26 93 9 37 15 68 49 99 73 48 79 16 27 52 4 66 53 48 55 27 56 52 66 25 30 34 11 97 20 38 30 4 78 17 98 4 23 30 71 87 94 89 71 45 92 72 24 90 24 78 48 62 82 30 30 27 55 64 66 41 72 53 97 59 38 80 ...

output:

10000000000000234.2236328125

result:

wrong answer 1st numbers differ - expected: '13395.8550625', found: '10000000000000234.0000000', error = '746499566718.1981201'