QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#719277#7988. 史莱姆工厂CryingWA 1ms5764kbC++141.5kb2024-11-06 23:54:502024-11-06 23:54:53

Judging History

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

  • [2024-11-06 23:54:53]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5764kb
  • [2024-11-06 23:54:50]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 160,K = 15,INF = 1e9;
template<typename T>void tomin(T& x,T y){x = min(x,y);}
template<typename T>void tomax(T& x,T y){x = max(x,y);}
//
int n,x,w,c[N],m[N],p[2*K];

int f[N][N],g[N][N][K],h[N][N][K];

int main(){
    cin>>n>>x>>w;
    for(int i=1;i<=n;i++)cin>>c[i];
    for(int i=1;i<=n;i++)cin>>m[i];
    for(int i=x;i<=2*x-2;i++)cin>>p[i];
    //
    for(int i=0;i<=n+1;i++)for(int j=0;j<=n+1;j++){
        f[i][j] = -INF;
        for(int k=0;k<x;k++)g[i][j][k] = h[i][j][k] = -INF;
    }
    for(int i=1;i<=n;i++)g[i][i][m[i]] = 0;
    for(int l=n;l>=1;l--){
        for(int r=l;r<=n;r++){
            for(int k=1;k<x;k++){
                tomax(f[l][r],g[l][r][k] - w*(x-k) + p[x]);
            }
            for(int nr=r+1;nr<=n;nr++){
                tomax(f[l][nr],f[l][r] + f[r+1][nr]);

                for(int k1=1;k1<x;k1++){
                    tomax(h[l][nr][k1],g[l][r][k1] + f[r+1][nr]);
                    if(c[r+1] != c[nr] || c[r+1] != c[l])continue;
                    for(int k2=1;k2<x;k2++){
                        if(k1+k2 < x){
                            tomax(g[l][nr][k1+k2],h[l][r][k1] + g[r+1][nr][k2]);
                        }else{
                            tomax(f[l][nr],h[l][r][k1] + g[r+1][nr][k2] + p[k1+k2]);
                        }
                    }
                }
            }
        }
    }
    cout<<f[1][n]<<endl;

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5764kb

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: 3668kb

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'