QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#325770 | #7988. 史莱姆工厂 | Hanghang | WA | 48ms | 11004kb | C++14 | 1.4kb | 2024-02-11 22:09:22 | 2024-02-11 22:09:23 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=153,M=13,INF=(ll)1e18;
ll n,m,w,a[N],b[N],c[N],f[N][N],fl[N][N][M],fr[N][N][M],g[N][N][M];
void Max(ll &x,ll y){if(x<y)x=y;}
int main()
{
cin>>n>>m>>w;
for(int i=1;i<=n;i++)cin>>c[i];
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=m;i<=2*m-2;i++)cin>>b[i];
memset(f,-0x3f,sizeof(f));memset(g,-0x3f,sizeof(g));
memset(fl,-0x3f,sizeof(fl));memset(fr,-0x3f,sizeof(fr));
for(int i=1;i<=n;i++)
fl[i][i][a[i]]=fr[i][i][a[i]]=f[i][i-1]=0,f[i][i]=b[m]-w*(m-a[i]);
for(int len=2;len<=n;len++)for(int l=1,r=len;r<=n;l++,r++)
{
if(c[l-1]!=c[r])Max(fr[l][r][a[r]],f[l][r-1]);
for(int k=l;k<r;k++)if(c[k]==c[r]&&c[l-1]!=c[k])
for(int p=1;p+a[r]<m;p++)Max(fr[l][r][p+a[r]],fr[l][k][p]+f[k+1][r-1]);
if(c[l]!=c[r+1])Max(fl[l][r][a[l]],f[l+1][r]);
for(int k=l+1;k<=r;k++)if(c[k]==c[l]&&c[r+1]!=c[k])
for(int p=1;p+a[l]<m;p++)Max(fl[l][r][p+a[l]],fl[k][r][p]+f[l+1][k-1]);
for(int k=l;k<=r;k++)if(c[k]!=c[l-1]&&c[k]!=c[r+1])
for(int p=1;p<m;p++)Max(f[l][r],fr[l][k][p]+f[k+1][r]+b[m]-w*(m-p));
for(int k=l;k<r;k++)if(c[k]==c[r]&&c[l-1]!=c[k])
for(int p=1;p<m;p++)Max(g[l][r][p],fr[l][k][p]+f[k+1][r-1]);
for(int k=l+1;k<=r;k++)if(c[k]!=c[r+1])
for(int x=1;x<m;x++)for(int y=1;y<m;y++)if(x+y>=m)
Max(f[l][r],g[l][k][x]+fl[k][r][y]+b[x+y]);
}
cout<<f[1][n];
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 11000kb
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: 0ms
memory: 10996kb
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: 47ms
memory: 10936kb
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: 45ms
memory: 10876kb
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: 0
Accepted
time: 48ms
memory: 10908kb
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:
300542698
result:
ok single line: '300542698'
Test #6:
score: 0
Accepted
time: 48ms
memory: 10876kb
input:
150 10 999660 2 1 7 4 6 1 6 2 1 3 4 6 2 7 2 3 2 4 8 3 5 8 7 8 3 5 7 3 4 6 7 6 3 5 6 8 4 2 3 7 6 5 8 7 5 2 4 8 4 8 3 6 4 6 2 8 4 5 3 5 6 3 5 4 5 2 7 5 1 8 1 3 2 1 7 5 7 8 2 5 1 4 3 7 5 8 6 3 7 2 1 5 2 3 5 3 7 2 7 8 5 8 1 5 6 1 6 4 7 5 1 5 1 2 5 2 8 7 5 6 7 6 7 6 2 7 6 8 6 5 4 3 8 7 2 8 6 3 6 1 2 6 8 ...
output:
670043245
result:
ok single line: '670043245'
Test #7:
score: 0
Accepted
time: 47ms
memory: 10996kb
input:
150 10 657385 9 8 2 1 8 2 3 8 9 7 1 9 1 7 3 2 3 9 3 1 6 2 4 1 8 1 7 3 2 8 7 6 8 2 3 9 8 5 1 7 8 1 3 5 8 5 6 3 9 6 5 8 3 4 1 3 8 1 8 6 2 5 2 9 8 5 2 4 7 3 2 3 1 3 7 2 5 1 2 9 8 9 8 6 8 4 7 6 3 8 5 7 2 8 5 8 6 5 1 3 8 2 1 7 3 6 3 5 2 7 8 1 9 5 8 3 6 2 7 3 8 7 4 1 7 5 3 4 1 4 6 5 4 7 3 9 3 9 7 5 8 7 5 ...
output:
617669855
result:
ok single line: '617669855'
Test #8:
score: 0
Accepted
time: 47ms
memory: 10992kb
input:
150 10 610355 10 1 7 9 8 2 9 4 10 8 9 3 5 1 10 5 10 4 5 6 7 6 10 9 7 9 3 4 7 5 2 6 10 3 2 10 8 3 5 2 5 8 6 2 9 6 3 8 6 5 4 9 3 1 5 3 2 9 4 2 4 10 9 4 5 2 3 5 9 3 5 1 5 3 7 5 3 9 6 1 7 3 7 5 1 3 9 1 6 4 10 7 9 5 9 7 3 7 4 9 2 3 4 9 10 3 1 4 3 1 6 9 1 8 1 3 8 2 8 1 6 1 5 4 10 2 9 3 9 5 2 6 8 3 9 5 2 3...
output:
531487920
result:
ok single line: '531487920'
Test #9:
score: 0
Accepted
time: 48ms
memory: 10856kb
input:
150 10 213291 5 2 9 4 11 7 1 6 11 7 4 10 8 5 11 6 11 9 8 3 6 3 8 7 3 6 4 9 5 2 7 11 2 8 5 1 11 2 3 1 10 8 7 4 11 9 7 5 3 10 9 6 7 5 4 9 3 8 10 8 3 11 3 5 6 8 10 1 5 3 1 9 2 7 3 7 2 5 6 2 11 5 11 6 7 1 7 3 7 8 11 5 4 10 3 8 7 5 1 10 5 2 1 7 3 8 7 2 9 2 1 10 4 7 8 11 6 4 10 1 2 9 5 4 8 11 3 7 1 11 1 7...
output:
152312585
result:
ok single line: '152312585'
Test #10:
score: 0
Accepted
time: 31ms
memory: 10996kb
input:
150 10 217802 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ...
output:
-11543506
result:
ok single line: '-11543506'
Test #11:
score: 0
Accepted
time: 23ms
memory: 11004kb
input:
150 10 173796 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ...
output:
-5909064
result:
ok single line: '-5909064'
Test #12:
score: 0
Accepted
time: 27ms
memory: 10956kb
input:
150 10 750989 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 ...
output:
-28537582
result:
ok single line: '-28537582'
Test #13:
score: 0
Accepted
time: 23ms
memory: 10992kb
input:
150 10 475760 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ...
output:
-27594080
result:
ok single line: '-27594080'
Test #14:
score: 0
Accepted
time: 0ms
memory: 10928kb
input:
5 7 300 2 3 2 3 2 5 6 6 6 4 1000 900 800 400 200 50
output:
2600
result:
ok single line: '2600'
Test #15:
score: 0
Accepted
time: 27ms
memory: 10884kb
input:
150 10 795836 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 ...
output:
-58891864
result:
ok single line: '-58891864'
Test #16:
score: 0
Accepted
time: 42ms
memory: 10880kb
input:
150 10 634984 1 3 2 1 3 2 1 2 3 1 3 1 2 3 1 2 3 2 3 1 3 2 1 3 2 1 2 3 1 2 1 2 1 3 2 1 3 2 3 1 2 1 2 1 3 1 3 2 3 1 2 1 2 3 1 2 1 2 1 2 3 1 2 1 3 1 2 1 3 1 2 3 2 3 1 2 3 1 2 1 3 2 3 2 3 1 2 1 2 1 3 2 1 3 2 3 2 3 1 2 1 3 2 1 2 3 1 3 1 2 3 1 2 3 1 2 1 2 3 2 1 3 1 3 1 3 1 3 2 1 3 1 3 2 3 2 3 2 3 1 3 1 2 ...
output:
-53338656
result:
ok single line: '-53338656'
Test #17:
score: 0
Accepted
time: 38ms
memory: 10860kb
input:
150 10 171347 1 3 1 3 1 3 1 3 2 1 3 1 3 2 1 2 1 3 1 2 1 2 3 1 3 1 3 1 3 1 3 2 3 2 3 1 2 3 1 3 2 1 2 1 3 1 2 1 2 1 2 1 3 1 2 1 3 2 1 3 1 3 1 2 3 2 3 1 2 3 2 1 2 3 1 2 3 2 3 2 3 1 2 3 1 2 1 2 1 3 2 3 2 1 2 3 2 1 2 3 1 2 3 1 3 1 2 1 3 2 1 2 1 3 2 3 2 1 3 2 1 3 2 3 2 3 2 3 1 2 3 2 1 3 1 3 1 2 1 3 1 3 2 ...
output:
-19362211
result:
ok single line: '-19362211'
Test #18:
score: -100
Wrong Answer
time: 42ms
memory: 10976kb
input:
150 10 963860 3 2 1 3 2 1 2 3 2 3 1 2 1 3 2 3 2 1 2 1 2 1 3 1 3 2 3 2 1 2 1 2 3 2 1 3 1 2 1 2 3 1 3 2 1 3 2 3 1 3 1 3 2 3 2 1 2 1 3 2 3 1 3 2 1 3 2 1 2 1 3 1 3 2 1 2 3 2 3 1 3 1 2 3 2 1 2 3 1 3 2 3 1 3 2 1 3 1 2 3 2 1 3 2 3 2 3 1 2 3 1 3 1 3 1 3 1 2 1 3 2 3 2 3 2 3 2 3 1 3 1 2 3 2 1 3 1 3 1 2 3 1 2 ...
output:
-83855820
result:
wrong answer 1st lines differ - expected: '-80964240', found: '-83855820'