QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#268991#5146. SkillsTerkML 0ms0kbC++141.4kb2023-11-29 09:51:062023-11-29 09:51:06

Judging History

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

  • [2023-11-29 09:51:06]
  • 评测
  • 测评结果:ML
  • 用时:0ms
  • 内存:0kb
  • [2023-11-29 09:51:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e3+10,W=220;
int n;
int Rem[N][4],Gy[N][W][W][4];
void Max(int &a,int b){
	if(b>a) a=b;
}
int nxt(int x){//注意不要直接+1 因为0的话就不会加 所以开个函数算方便 
	return x==0?0:x+1;
}
int main(){
	int t;
	cin>>t;
	while(t--){
		cin>>n;
		for(int i=1;i<=n;i++) cin>>Rem[i][1]>>Rem[i][2]>>Rem[i][3];
		memset(Gy,-0x3f,sizeof(Gy));
		Gy[0][0][0][1]=Gy[0][0][0][2]=Gy[0][0][0][3]=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<205;j++){
				for(int k=0;k<205;k++){
					Max(Gy[i+1][nxt(j)][nxt(k)][1],Gy[i][j][k][1]+Rem[i+1][1]-nxt(j)-nxt(k));
					Max(Gy[i+1][1][nxt(k)][2],Gy[i][j][k][1]+Rem[i+1][2]-nxt(k)-1);
					Max(Gy[i+1][nxt(j)][1][3],Gy[i][j][k][1]+Rem[i+1][3]-nxt(j)-1);
									
					Max(Gy[i+1][1][nxt(k)][1],Gy[i][j][k][2]+Rem[i+1][1]-nxt(k)-1);
					Max(Gy[i+1][nxt(j)][nxt(k)][2],Gy[i][j][k][2]+Rem[i+1][2]-nxt(j)-nxt(k));
					Max(Gy[i+1][nxt(j)][1][3],Gy[i][j][k][2]+Rem[i+1][3]-nxt(j)-1);
					
					
					Max(Gy[i+1][nxt(k)][1][1],Gy[i][j][k][3]+Rem[i+1][1]-nxt(k)-1);
					Max(Gy[i+1][nxt(j)][1][2],Gy[i][j][k][3]+Rem[i+1][2]-nxt(j)-1);
					Max(Gy[i+1][nxt(j)][nxt(k)][3],Gy[i][j][k][3]+Rem[i+1][3]-nxt(j)-nxt(k));
					
				}
			}
		}
		int ans=0;//可以都不选 
		for(int j=0;j<205;j++){
			for(int k=0;k<205;k++){
				ans=max(ans,max(Gy[n][j][k][1],max(Gy[n][j][k][2],Gy[n][j][k][3])));
			}
		}
		cout<<ans<<'\n';
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Memory Limit Exceeded

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: