QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#635523#5146. Skillsbruteforce_WA 75ms5360kbC++201.8kb2024-10-12 20:03:172024-10-12 20:03:17

Judging History

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

  • [2024-10-12 20:03:17]
  • 评测
  • 测评结果:WA
  • 用时:75ms
  • 内存:5360kb
  • [2024-10-12 20:03:17]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int inf=1e18,mod=998244353;
void O_o()
{
	int n;
	cin>>n;
	int N=min(205ll,n);
	vector<array<int,3>> a(n+1);
	for(int i=1; i<=n; i++)
	{
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	}
	vector dp1(N+2,vector<int>(N+2)),dp2(N+2,vector<int>(N+2)),dp3(N+2,vector<int>(N+2));
	for(int i=1; i<=n; i++)
	{
		vector dpn1(N+2,vector<int>(N+2)),dpn2(N+2,vector<int>(N+2)),dpn3(N+2,vector<int>(N+2));
		for(int j=0; j<=N; j++)
		{
			for(int k=0; k<=N; k++)
			{
				int nj=j>0?(j+1):0,nk=k>0?(k+1):0;
				int j1=(i>1),k1=(i>1);
				
				dpn1[nj][nk]=max(dpn1[nj][nk],dp1[j][k] + a[i][0] - nj - nk);
				dpn1[j1][nk]=max(dpn1[j1][nk],dp2[j][k] + a[i][0] - nk - k1);
				dpn1[nj][k1]=max(dpn1[nj][k1],dp3[j][k] + a[i][0] - nj - j1);
				
				dpn2[nj][nk]=max(dpn2[nj][nk],dp2[j][k] + a[i][1] - nj - nk);
				dpn2[j1][nk]=max(dpn2[j1][nk],dp1[j][k] + a[i][1] - nk - k1);
				dpn2[nj][k1]=max(dpn2[nj][k1],dp3[j][k] + a[i][1] - nj - j1);
				
				dpn3[nj][nk]=max(dpn3[nj][nk],dp3[j][k] + a[i][2] - nj - nk);
				dpn3[j1][nk]=max(dpn3[j1][nk],dp1[j][k] + a[i][2] - nk - k1);
				dpn3[nj][k1]=max(dpn3[nj][k1],dp2[j][k] + a[i][2] - nj - j1);
			}
		}
		dp1=dpn1;
		dp2=dpn2;
		dp3=dpn3;
	}
	int ans=0;
	for(int i=0; i<=N; i++)
	{
		for(int j=0; j<=N; j++)
		{
			ans=max(ans,dp1[i][j]);
			ans=max(ans,dp2[i][j]);
			ans=max(ans,dp3[i][j]);
		}
	}
	cout<<ans<<"\n";
}
signed main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cout<<fixed<<setprecision(12);
	int T=1;
	cin>>T;
	while(T--)
	{
		O_o();
	}
}
// dp1[i][j][k] + a[i][0] - nj - nk -> dp1[i+1][nj][nk]
// dp2[i][j][k] + a[i][0] - nk - 1 -> dp1[i+1][j1][nk]
// dp3[i][j][k] + a[i][0] - nj - 1 -> dp1[i+1][nj][k1]













详细

Test #1:

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

input:

2
3
1 1 10
1 10 1
10 1 1
5
1 2 3
6 5 4
7 8 9
12 11 10
13 14 15

output:

26
41

result:

ok 2 number(s): "26 41"

Test #2:

score: -100
Wrong Answer
time: 75ms
memory: 5360kb

input:

1
200
6219 3608 2383
1139 2158 8611
6721 8216 8887
8736 6707 9755
7210 248 167
3849 276 8050
971 5062 1914
8290 1562 6017
8993 7990 3460
6323 6099 757
7652 4740 6117
6560 4206 180
3705 8906 5752
9619 8939 9696
793 6680 1777
384 3606 8772
9258 3906 709
4396 5083 6614
6057 4410 3132
8596 825 7437
6098...

output:

1505359

result:

wrong answer 1st numbers differ - expected: '1505431', found: '1505359'