QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#536494#7988. 史莱姆工厂tarjenWA 0ms3548kbC++201.4kb2024-08-29 13:47:162024-08-29 13:47:20

Judging History

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

  • [2024-08-29 13:47:20]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3548kb
  • [2024-08-29 13:47:16]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int maxn=151;
int dp[maxn][maxn],vis[maxn][maxn];
void gmax(int &x,int y){
    if(y>x)x=y;
}
int n,k,w;
int c[maxn],m[maxn],p[maxn];
vector<int> ve[maxn];
int val(int x){
    if(x>=k)return p[x];
    else return p[k]-(k-x)*w;
}
int dfs(int l,int r){
    if(l>r)return 0;
    if(vis[l][r])return dp[l][r];
    int res=-2e9;
    if(l==r)res=p[k]-(k-m[l])*w;
    else{
        vector<vector<int>>dp(r-l+1+1,vector<int>(k+1,-(int)2e9));
        dp[0][0]=0;
        int len=r-l+1;
        for(int i=0;i<len;i++){
            for(int j=i+1;j<=len;j++)if(i==0||c[i+l-1]==c[j+l-1]){
                for(int z=0;z<k;z++){
                    if(z+m[j+l-1]>=k){
                        gmax(res,dp[i][z]+dfs(i+l-1+1,j+l-1-1)+val(z+m[j+l-1])+dfs(j+l-1+1,r));
                    }
                    else{
                        gmax(dp[j][z+m[j+l-1]],dp[i][z]+dfs(i+l-1+1,j+l-1-1));
                        gmax(res,dp[j][z+m[j+l-1]]+val(z+m[j+l-1])+dfs(j+l-1+1,r));
                    }
                }
            }
        }
    }
    vis[l][r]=1;
    // cout<<"l="<<l<<" r="<<r<<" dp="<<res<<endl;
    return dp[l][r]=res;
}
int main()
{
    cin>>n>>k>>w;
    for(int i=1;i<=n;i++)cin>>c[i],ve[c[i]].push_back(i);
    for(int i=1;i<=n;i++)cin>>m[i];
    for(int i=k;i<=k*2-2;i++)cin>>p[i];
    cout<<dfs(1,n);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: -100
Wrong Answer
time: 0ms
memory: 3516kb

input:

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

output:

2300

result:

wrong answer 1st lines differ - expected: '1400', found: '2300'