比赛 |
20231212_2010联赛题复现 |
评测结果 |
AAAAAAAAAA |
题目名称 |
乌龟棋 |
最终得分 |
100 |
用户昵称 |
┭┮﹏┭┮ |
运行时间 |
0.004 s |
代码语言 |
C++ |
内存使用 |
3.52 MiB |
提交时间 |
2023-12-12 20:30:43 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 400,M = 200,F = 42;
int n,m,a[N],b[M],l[4];
int f[F][F][F][F];
int main(){
freopen("tortoise.in","r",stdin);
freopen("tortoise.out","w",stdout);
scanf("%d%d",&n,&m);
for(int i = 1;i <= n;i++)scanf("%d",&a[i]);
for(int i = 1;i <= m;i++){
scanf("%d",&b[i]);
l[b[i]]++;
}
f[0][0][0][0] = a[1];
for(int i = 0;i <= l[1];i++){
for(int j = 0;j <= l[2];j++){
for(int k = 0;k <= l[3];k++){
for(int p = 0;p <= l[4];p++){
int s = f[i][j][k][p],u = a[1+i+2*j+3*k+4*p];
if(i > 0)s = max(s,f[i-1][j][k][p]+u);
if(j > 0)s = max(s,f[i][j-1][k][p]+u);
if(k > 0)s = max(s,f[i][j][k-1][p]+u);
if(p > 0)s = max(s,f[i][j][k][p-1]+u);
f[i][j][k][p] = s;
}
}
}
}
printf("%d\n",f[l[1]][l[2]][l[3]][l[4]]);
return 0;
}