QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#530903#5303. No Bug No GamesyssCompile Error//C++201.4kb2024-08-24 17:35:582024-08-24 17:36:03

Judging History

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

  • [2024-08-24 17:36:03]
  • 评测
  • [2024-08-24 17:35:58]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
int p[30005];
int a[15][3005];
int dp[2][3005][3005];
int ans;
void solve() 
{
	int n,k;
	cin>>n>>k;
	ll sum=0;
	for(int i=1;i<=n;i++)
	{
		cin>>p[i];
		sum+=p[i];
		for(int j=1;j<=p[i];j++)
		{
			cin>>a[j][i];
		}
	}
	
	if(sum<k)
	{
		ans=0;
		for(int i=1;i<=n;i++)
		{
			ans+=a[p[i]][i];
		}
		cout<<ans<<'\n';
		return;
	}
	for(int i=0;i<2;i++)
	{
		for(int j=0;j<=n;j++)
		{
			for(int l=0;l<=n;l++)
			{
				dp[i][j][l]=-1;
			}
		}
	}
	dp[0][0][0]=0;
	dp[1][n+1][0]=0;
	for(int i=n;i>=1;i--)
	{
		for(int j=0;j<=k;j++)
		{
			dp[1][i][j]=dp[1][i+1][j];
			if(j>=p[i]&&dp[1][i+1][j-p[i]]!=-1)
			{
				dp[1][i][j]=max(dp[1][i][j],dp[1][i+1][j-p[i]]+a[p[i]][i]);
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=k;j++)
		{
			dp[0][i][j]=dp[0][i-1][j];
			if(j>=p[i]&&dp[0][i-1][j-p[i]]!=-1)
			{
				dp[0][i][j]=max(dp[0][i][j],dp[0][i-1][j-p[i]]+a[p[i]][i]);
			}
		}
	}
	ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=p[i];j++)
		{
			ll tmp=k-j;
			for(int l=0;l<=tmp;l++)
			{
				int tem=tmp-l;
				if(dp[0][i-1][l]!=-1&&dp[1][i+1][tem]!=-1)
				{
					ans=max(ans,dp[0][i-1][l]+dp[1][i+1][tem]+a[j][i]);
				}
			}
		}
	}
	cout<<ans<<'\n';
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--)
		solve();
}

詳細信息

answer.code: In function ‘void solve()’:
answer.code:12:9: error: ‘ll’ was not declared in this scope
   12 |         ll sum=0;
      |         ^~
answer.code:16:17: error: ‘sum’ was not declared in this scope
   16 |                 sum+=p[i];
      |                 ^~~
answer.code:23:12: error: ‘sum’ was not declared in this scope
   23 |         if(sum<k)
      |            ^~~
answer.code:72:27: error: expected ‘;’ before ‘tmp’
   72 |                         ll tmp=k-j;
      |                           ^~~~
      |                           ;
answer.code:73:40: error: ‘tmp’ was not declared in this scope; did you mean ‘tm’?
   73 |                         for(int l=0;l<=tmp;l++)
      |                                        ^~~
      |                                        tm