QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#268999 | #5146. Skills | Terk | WA | 75ms | 498276kb | C++14 | 2.0kb | 2023-11-29 10:00:15 | 2023-11-29 10:00:16 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1e3+5,W=205;
namespace IO
{
char Is[(1<<21)+10],Os[(1<<21)+10];
int Ipt,Opt;
char gc()
{
if(Ipt==1<<21)Ipt=0;
if(!Ipt){Is[fread(Is,1,1<<21,stdin)]=0;}
return Is[Ipt++];
}
void flush(){fwrite(Os,1,Opt,stdout);Opt=0;}
void pc(char x)
{
if(Opt==1<<21)flush();
Os[Opt++]=x;
}
int read()
{
int x=0;char ch=gc();while(ch<'0'||ch>'9')ch=gc();while(ch<='9'&&ch>='0')x=x*10+ch-'0',ch=gc();return x;
}
}
using namespace IO;
int n;
int Rem[N][3],Gy[N][W][W][3];
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++) Rem[i][0]=read(),Rem[i][1]=read(),Rem[i][2]=read();
memset(Gy,-0x3f,sizeof(Gy));
Gy[0][0][0][0]=Gy[0][0][0][1]=Gy[0][0][0][2]=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)][0],Gy[i][j][k][0]+Rem[i+1][0]-nxt(j)-nxt(k));
Max(Gy[i+1][1][nxt(k)][1],Gy[i][j][k][0]+Rem[i+1][1]-nxt(k)-1);
Max(Gy[i+1][1][nxt(j)][2],Gy[i][j][k][0]+Rem[i+1][2]-nxt(j)-1);
Max(Gy[i+1][1][nxt(k)][0],Gy[i][j][k][1]+Rem[i+1][0]-nxt(k)-1);
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][nxt(j)][1][2],Gy[i][j][k][1]+Rem[i+1][2]-nxt(j)-1);
Max(Gy[i+1][nxt(k)][1][0],Gy[i][j][k][2]+Rem[i+1][0]-nxt(k)-1);
Max(Gy[i+1][nxt(j)][1][1],Gy[i][j][k][2]+Rem[i+1][1]-nxt(j)-1);
Max(Gy[i+1][nxt(j)][nxt(k)][2],Gy[i][j][k][2]+Rem[i+1][2]-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][0],max(Gy[n][j][k][1],Gy[n][j][k][2])));
}
}
cout<<ans<<'\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 75ms
memory: 498276kb
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 15
result:
wrong answer 2nd numbers differ - expected: '41', found: '15'