QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#735424#5303. No Bug No GameEMTzWA 59ms225196kbC++201.3kb2024-11-11 19:55:192024-11-11 19:55:19

Judging History

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

  • [2024-11-11 19:55:19]
  • 评测
  • 测评结果:WA
  • 用时:59ms
  • 内存:225196kb
  • [2024-11-11 19:55:19]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define ull unsigned long long
using namespace std;
typedef pair<int,int>PII;
typedef pair<int,PII>PPI;
typedef array<int,3>ar;
typedef __int128 i28; 
const int N=3000+100;
const int N1=1e9+9;
const int M=998244353;
const ull mask = std::chrono::steady_clock::now().time_since_epoch().count();
mt19937_64 rng(time(0));
const int M1=19260817;
const int base=233;
const int base1=131;
const int INF = 0x3f3f3f3f;
int val[N][N];
int p[N];
int dp[2][N][N];
int dp1[N];
void solve()
{
	int n,k;	
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>p[i];
		for(int j=1;j<=p[i];j++)
		{
			cin>>val[i][j];
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=p[i];j<=k;j++)
		{
			dp[0][i][j]=max(dp[0][i-1][j],dp[0][i-1][j-p[i]]+val[i][p[i]]);
		}
	}
	for(int i=n;i>=1;i--)
	{
		for(int j=p[i];j<=k;j++)
		{
			dp[1][i][j]=max(dp[1][i+1][j],dp[1][i+1][j-p[i]]+val[i][p[i]]);
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=max(0ll,k-p[i]);j<=k;j++)
		{
			for(int z=0;z<=j;z++)
			{
				dp1[j]=max({dp1[j],dp[0][i-1][z]+dp[1][i+1][j-z]});
			}
			ans=max(ans,dp1[j]+val[i][k-j]);
		}
	}
	cout<<ans<<"\n";
}
signed main()
{
	std::ios::sync_with_stdio(false);
	cout.tie(0);cin.tie(0);
	int _=1;
//	cin>>_;
	while(_--)
	{
		solve();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 5
2 1 3
2 1 1
2 3 1
2 1 3

output:

9

result:

ok 1 number(s): "9"

Test #2:

score: -100
Wrong Answer
time: 59ms
memory: 225196kb

input:

3000 3000
10 70562 30723 79371 82224 63977 3362 26909 96449 48163 66159
4 18007 33590 80674 91139
4 10304 31694 70745 50656
10 63090 17226 13187 73881 38137 15237 55750 82751 75854 39658
8 95640 66120 87735 36388 44046 92415 6952 94772
9 60565 27904 98726 87052 35768 25453 14563 34273 92501
10 66332...

output:

68260580

result:

wrong answer 1st numbers differ - expected: '68279788', found: '68260580'