QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#396316#7988. 史莱姆工厂zyxawaWA 7ms11596kbC++141.8kb2024-04-22 17:26:092024-04-22 17:26:09

Judging History

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

  • [2024-04-22 17:26:09]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:11596kb
  • [2024-04-22 17:26:09]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,s,w,c[151],m[151],p[21];
ll f[151][151],fl[151][151][21],fr[151][151][21];
void upd(ll &x,ll y){x=max(x,y);}
int main(){
	memset(f,-0x3f,sizeof(f)),memset(fl,-0x3f,sizeof(fl)),memset(fr,-0x3f,sizeof(fr));
	scanf("%d%d%d",&n,&s,&w),c[0]=-1;
	for(int i=1;i<=n;i++) scanf("%d",&c[i]);
	for(int i=1;i<=n;i++) scanf("%d",&m[i]);
	for(int i=s;i<=2*s-2;i++) scanf("%d",&p[i]);
	for(int i=1;i<s;i++) p[i]=p[s]-(s-i)*w;
	for(int i=1;i<=n;i++) f[i][i]=p[m[i]],fl[i][i][m[i]]=fr[i][i][m[i]]=f[i][i-1]=0;
	for(int t=2;t<=n;t++){
		for(int l=1;l+t-1<=n;l++){
			int r=l+t-1;
			upd(fl[l][r][m[l]],f[l+1][r]);for(int k=l+1;k<r;k++) if(c[k]==c[l]) for(int i=1;i<s-m[k]-1;i++) upd(fl[l][r][i+m[k]],fl[l][k-1][i]+f[k+1][r]);
			upd(fr[l][r][m[r]],f[l][r-1]);for(int k=l+1;k<r;k++) if(c[k]==c[l]) for(int i=1;i<s-m[k]-1;i++) upd(fr[l][r][i+m[k]],fr[k+1][r][i]+f[l][k-1]);
			// if(c[l]!=c[r+1]){
			// 	upd(fl[l][r][m[l]],f[l+1][r]);
			// 	for(int k=l-1;k<r;k++) if(c[k+1]==c[l]) for(int i=1;i+m[l]<s;i++) upd(fl[l][r][i+m[l]],f[l][k]+fl[k+1][r][i]);
			// }
			// if(c[r]!=c[l-1]){
			// 	upd(fr[l][r][m[l]],f[l][r-1]);
			// 	for(int k=l;k<=r;k++) if(c[k]==c[r]) for(int i=1;i+m[r]<s;i++) upd(fr[l][r][i+m[r]],f[k+1][r]+fr[l][k][i]);
			// }
			// if(c[l-1]==c[r+1]) continue;
			for(int k=l;k<r;k++) if(c[k]!=c[r+1]||c[k+1]!=c[l-1]) upd(f[l][r],f[l][k]+f[k+1][r]);
			if(c[l]!=c[r]) continue;
			 upd(f[l][r],f[l+1][r-1]+p[m[l]+m[r]]);
			 for(int k=l+1;k<r;k++){
			 	if(c[k]==c[l]){
			 		for(int i=1;i<s;i++){
						for(int j=1;j<s;j++){
			 				if(i+m[k]<s||j+m[k]<s) upd(f[l][r],fl[l][k-1][i]+fr[k+1][r][j]+p[i+j+m[k]]);
						}
			 		}
			 	}
			 }
		}
	}
	printf("%lld",f[1][n]);
	return 0;
}
//dp[l][r][k][c]区间[l,r]剩

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 11504kb

input:

4 5 6
2 1 2 3
3 3 3 4
5 7 9 11

output:

-1

result:

ok single line: '-1'

Test #2:

score: 0
Accepted
time: 2ms
memory: 11596kb

input:

5 7 500
2 3 2 3 2
5 6 6 6 4
1000 900 800 400 200 50

output:

1400

result:

ok single line: '1400'

Test #3:

score: 0
Accepted
time: 7ms
memory: 11592kb

input:

150 10 465782
6 1 4 3 2 6 1 3 5 3 4 6 1 2 1 5 1 6 2 1 5 4 6 1 3 2 6 5 4 3 1 6 3 4 1 4 1 6 3 6 1 4 2 4 6 4 3 1 5 6 4 2 1 4 6 2 5 1 3 1 4 6 5 6 3 2 3 4 2 3 6 3 5 2 6 1 5 4 5 2 4 1 4 3 4 1 3 2 6 1 4 5 4 6 2 1 3 1 2 1 3 5 2 3 2 6 5 3 1 4 1 5 1 6 2 5 4 2 4 1 4 2 5 6 4 3 5 1 3 2 5 4 6 4 3 5 3 4 5 3 2 1 4 ...

output:

392867316

result:

ok single line: '392867316'

Test #4:

score: 0
Accepted
time: 3ms
memory: 11532kb

input:

150 10 10105
8 6 8 6 8 3 8 5 8 5 1 5 1 5 6 5 6 5 6 7 6 5 6 1 6 4 6 4 3 4 9 4 1 4 1 4 1 5 1 9 1 4 1 9 1 9 3 9 1 9 5 9 8 9 8 5 8 7 8 4 8 6 8 6 2 6 9 6 4 6 5 6 5 3 5 1 5 4 5 8 5 8 9 8 7 8 6 8 1 8 1 8 1 8 1 6 1 7 1 7 2 7 4 7 6 7 4 7 4 5 4 7 4 7 4 3 4 3 7 3 2 3 8 3 4 3 4 8 4 7 4 9 4 2 4 2 7 2 8 2 7 2 9 2...

output:

9262990

result:

ok single line: '9262990'

Test #5:

score: -100
Wrong Answer
time: 6ms
memory: 11448kb

input:

150 10 491282
5 7 1 4 5 3 5 3 5 6 7 3 6 3 4 5 4 2 3 7 3 4 7 2 3 7 5 4 6 1 7 5 2 6 4 1 6 2 5 4 1 3 6 7 5 6 2 1 3 2 1 7 1 2 6 1 2 6 4 3 7 6 5 3 5 4 1 2 7 1 5 6 2 6 5 1 3 5 6 3 4 5 1 3 7 4 6 4 2 6 3 7 5 7 1 2 7 4 3 2 1 4 2 7 4 6 2 3 6 4 7 1 5 3 2 1 3 4 3 6 7 3 7 5 6 2 4 2 1 3 2 3 7 5 3 5 6 4 6 1 2 6 7 ...

output:

300964294

result:

wrong answer 1st lines differ - expected: '300542698', found: '300964294'