QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#312468#5146. SkillsJ1926817ML 0ms0kbC++171.7kb2024-01-23 22:10:352024-01-23 22:10:36

Judging History

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

  • [2024-01-23 22:10:36]
  • 评测
  • 测评结果:ML
  • 用时:0ms
  • 内存:0kb
  • [2024-01-23 22:10:35]
  • 提交

answer

#include <bits/extc++.h>

using namespace std;
int f[1111][210][210][3]{};int a[1111][3]{};
int main()
{
    ////cin.tie(0)->sync_with_stdio(0);cout.tie(0);
    int t;cin >> t;
    while(t--) {
        __builtin_memset(f,0,sizeof f);
        int n;cin >> n;
        int as{};
        for(int i = 1;i <= n; ++i)cin >> a[i][0] >> a[i][1] >> a[i][2];
//        for(int i=1;i <= n;++i)for(int x=0;x<=200;++x)for(int y=0;y<=200;++y)for(int k=0;k<3;++k) {
//            int nx=x?x+1:0, ny=y?y+1:0;
//            f[i][nx][ny][k]=max(f[i][nx][ny][k],f[i-1][x][y][k]-nx-ny+a[i][k]);
//            f[i][ny][1][(k+1)%3]=max(f[i][ny][1][(k+1)%3],f[i-1][x][y][k]-1-ny+a[i][(k+1)%3]);
//            f[i][1][nx][(k+1)%3]=max(f[i][1][nx][(k+1)%3],f[i-1][x][y][k]-1-nx+a[i][(k+2)%3]);
//        }
        for(int i = 1;i <= n; ++i) {
            int mm = min(194,n);
            for(int j = 0;j < mm; ++j)for(int k = 0;k < mm;++k) {
                for(int l = 0;l < 3; ++l) {
                        ///cout<<f[i][j][k][l]<<"\t";
                    int nj = j?j+1:0, nk = k?k+1:0;
                    f[i][nj][nk][l] = max(f[i][nj][nk][l],f[i-1][j][k][l] + a[i][l] - nj - nk);
                    f[i][nk][1][(l+1)%3] = max(f[i][nk][1][(l+1)%3],f[i-1][j][k][l] + a[i][(l+1)%3] - 1 - nk);
                    f[i][1][nj][(l+2)%3] = max(f[i][1][nj][(l+2)%3],f[i-1][j][k][l] + a[i][(l+2)%3] - 1 - nj);
                }
            }
            ///cout<<"\n--------\n";;
        }

            int a, b, c;
            for(int j = 0;j <= 200; ++j)for(int k = 0;k <= 200;++k)for(int l = 0;l < 3;++l) {
//                    cout<<f[n][j][k][l]<<"\t";
                as = max(as,f[n][j][k][l]);
            }

        cout<<as<<"\n";
    }
}

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: