QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#534660#7988. 史莱姆工厂Ecrade_WA 0ms3804kbC++142.1kb2024-08-27 14:55:482024-08-27 14:55:49

Judging History

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

  • [2024-08-27 14:55:49]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3804kb
  • [2024-08-27 14:55:48]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,w,p[20],a[159],c[159],f[159][159],g[159][159][10][10],h[159];
inline ll read(){
	ll s = 0,w = 1;
	char ch = getchar();
	while (ch > '9' || ch < '0'){ if (ch == '-') w = -1; ch = getchar();}
	while (ch <= '9' && ch >= '0') s = (s << 1) + (s << 3) + (ch ^ 48),ch = getchar();
	return s * w;
}
inline void chkmax(ll &x,ll y){if (x < y) x = y;}
int main(){
	n = read(),m = read(),w = read();
	for (ll i = 1;i <= n;i += 1) c[i] = read();
	for (ll i = 1;i <= n;i += 1) a[i] = read();
	for (ll i = m;i <= 2 * m - 2;i += 1) p[i] = read();
	for (ll i = 1;i <= n;i += 1) for (ll j = 1;j <= n;j += 1){
		f[i][j] = -1e18;
		for (ll k = 0;k < m;k += 1) for (ll l = 0;l < m;l += 1) g[i][j][k][l] = -1e18;
	}
	for (ll i = n;i >= 1;i -= 1){
		ll cnt = 0;
		for (ll j = i;j <= n;j += 1){
			cnt += (c[i] == c[j]) * a[j];
			if (i == j){
				f[i][j] = p[m] - w * (m - a[i]);
				g[i][j][a[i]][0] = 0;
				continue;
			}
			ll res = -1e18;
			for (ll k = 0;k <= min(m - 1,cnt);k += 1){
				for (ll l = 0;l <= m - 1 && k + l <= cnt;l += 1){
					if (c[i] == c[j]){
						if (k >= a[j] && !l) chkmax(g[i][j][k][l],g[i][j - 1][k - a[j]][l]);
						if (l >= a[j]) chkmax(g[i][j][k][l],g[i][j - 1][k][l - a[j]]);
//						if (i == 2 && j == 4) cout<<k<<' '<<l<<' '<<g[i][j][k][l]<<"HHH"<<endl;
						if (k + l < m) chkmax(res,g[i][j][k][l] + p[m] - w * (m - k - l));
						else chkmax(res,g[i][j][k][l] + p[k + l]);
					}
                    for (ll o = i;o < j;o += 1){
                        if (c[i] == c[j] && c[o] == c[j + 1]) continue;
                        chkmax(g[i][j][k][l],g[i][o][k][l] + f[o + 1][j]);
//						if (i == 1 && j == 2) cout<<k<<' '<<l<<' '<<o<<' '<<g[i][j][k][l]<<"WTF"<<endl;
                    }
				}
			}
			if (c[i] == c[j]) f[i][j] = res;
		}
	}
	for (ll i = 1;i <= n;i += 1) for (ll j = i;j <= n;j += 1) cout<<i<<'.'<<j<<' '<<f[i][j]<<endl;
    for (ll i = 1;i <= n;i += 1){
        h[i] = -1e18;
        for (ll j = 1;j <= i;j += 1) chkmax(h[i],h[j - 1] + f[j][i]);
    }
	printf("%lld",h[n]);
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3804kb

input:

4 5 6
2 1 2 3
3 3 3 4
5 7 9 11

output:

1.1 -7
1.2 -1000000000000000000
1.3 0
1.4 -1000000000000000000
2.2 -7
2.3 -1000000000000000000
2.4 -1000000000000000000
3.3 -7
3.4 -1000000000000000000
4.4 -1
-1

result:

wrong answer 1st lines differ - expected: '-1', found: '1.1 -7'