比赛 |
NOIP水题赛 |
评测结果 |
AAAAAAAAAA |
题目名称 |
AABD(无题面) |
最终得分 |
100 |
用户昵称 |
胡嘉兴 |
运行时间 |
1.100 s |
代码语言 |
C++ |
内存使用 |
191.77 MiB |
提交时间 |
2018-10-31 12:12:55 |
显示代码纯文本
#include<bits/stdc++.h>
#define ll long long
#define lowbit(x) (x&-x)
using namespace std;
const int N = 5e3+7, inf = 1e9+7;
ll f[N][N];
ll x[N], a[N], b[N], c[N], d[N];
int main()
{
int n;
freopen("AABD.in", "r", stdin);
freopen("AABD.out", "w", stdout);
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
scanf("%lld", &x[i]);
}
for(int i = 1; i <= n; i++)
{
scanf("%lld", &a[i]);
}
for(int i = 1; i <= n; i++)
{
scanf("%lld", &b[i]);
}
for(int i = 1; i <= n; i++)
{
scanf("%lld", &c[i]);
}
for(int i = 1; i <= n; i++)
{
scanf("%lld", &d[i]);
}
memset(f, 0xcf, sizeof(f));
f[0][0] = 0;
for(int i = 1; i <= n; i++)
{
f[i][1] = max(f[i][1], f[i-1][0]+b[i]+d[i]-2*x[i]);
for(int j = 1; j < i; j++)
{
f[i][j] = max(f[i][j], f[i-1][j]+a[i]+d[i]);
f[i][j] = max(f[i][j], f[i-1][j]+b[i]+c[i]);
f[i][j-1] = max(f[i][j-1], f[i-1][j]+a[i]+c[i]+2*x[i]);
f[i][j+1] = max(f[i][j+1], f[i-1][j]+b[i]+d[i]-2*x[i]);
}
}
printf("%lld\n", f[n][0]);
return 0;
}