Submission #1056558

# Submission time Handle Problem Language Result Execution time Memory
1056558 2024-08-13T10:01:51 Z amirhoseinfar1385 Catfish Farm (IOI22_fish) C++17
0 / 100
1000 ms 179144 KB
#include "fish.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn=100000+10,maxh=3000+10;
int n,m;
vector<pair<int,int>>allc[maxn];
long long dpn[maxh][maxh],dps[maxh][maxh],nau[maxh][maxh],inf=1e16,all[maxh][maxh];

long long solve(){
    for(int i=0;i<=n;i++){
        nau[0][i]=-inf;
        dpn[0][i]=dps[0][i]=-inf;
    }
    nau[0][0]=0;
    long long mainres=0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=n;j++){
            dpn[i][j]=dps[i][j]=0;
        }
        long long unnow=-inf;
        for(int j=n;j>=0;j--){
            dpn[i][j]=max(dpn[i][j],unnow);
            dpn[i][j]=max(dpn[i-1][j],dpn[i][j]);
            if(i==n){
                mainres=max(mainres,dpn[i][j]);
            }
            unnow=max(unnow,dpn[i-1][j])+all[i][j];
        }
        unnow=-inf;
        for(int j=0;j<=n;j++){
            unnow=max(unnow+all[i-1][j],dps[i-1][j]);
            dps[i][j]=max(dps[i][j],unnow);
            if(i==n){
                mainres=max(mainres,dps[i][j]);
            }
        }
        unnow=-inf;
        for(int j=n;j>=0;j--){
            unnow=max(unnow,nau[i-1][j]);
            dps[i][j]=max(dps[i][j],unnow);
            dpn[i][j]=max(dpn[i][j],unnow);
        }
        unnow=-inf;
        for(int j=0;j<=n;j++){
            unnow=max(unnow+all[i-1][j],nau[i-1][j]);
            dps[i][j]=max(dps[i][j],unnow);
            dpn[i][j]=max(dpn[i][j],unnow);
        }
        unnow=0;
        for(int j=n;j>=0;j--){
            unnow+=all[i][j];
            nau[i][j]=max(dpn[i-1][j],dps[i-1][j])+unnow;
        }
    }
   /* for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            cout<<dps[i][j]<<" ";
        }
        cout<<"\n";
    }
    cout<<"\n";
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            cout<<dpn[i][j]<<" ";
        }
        cout<<"\n";
    }
    cout<<"\n";
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            cout<<nau[i][j]<<" ";
        }
        cout<<"\n";
    }*/
    return mainres;
}

long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
                      std::vector<int> W) {
    n=N;
    m=M;
    for(int i=0;i<m;i++){
        Y[i]++;
        X[i]++;
        all[X[i]][Y[i]]+=W[i];
        allc[X[i]].push_back(make_pair(Y[i],W[i]));
    }
    for(int i=0;i<=n;i++){
        allc[i].push_back(make_pair(1,0));
        allc[i].push_back(make_pair(n,0));
        sort(allc[i].begin(),allc[i].end());
    }
    return solve();
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1062 ms 179144 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 9052 KB Output is correct
2 Execution timed out 1091 ms 177464 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1060 ms 155988 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 9052 KB Output is correct
2 Correct 1 ms 9048 KB Output is correct
3 Correct 1 ms 9052 KB Output is correct
4 Correct 1 ms 9052 KB Output is correct
5 Correct 2 ms 9052 KB Output is correct
6 Correct 1 ms 9052 KB Output is correct
7 Correct 1 ms 9052 KB Output is correct
8 Correct 1 ms 9052 KB Output is correct
9 Incorrect 2 ms 23644 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '322678674638'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 9052 KB Output is correct
2 Correct 1 ms 9048 KB Output is correct
3 Correct 1 ms 9052 KB Output is correct
4 Correct 1 ms 9052 KB Output is correct
5 Correct 2 ms 9052 KB Output is correct
6 Correct 1 ms 9052 KB Output is correct
7 Correct 1 ms 9052 KB Output is correct
8 Correct 1 ms 9052 KB Output is correct
9 Incorrect 2 ms 23644 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '322678674638'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 9052 KB Output is correct
2 Correct 1 ms 9048 KB Output is correct
3 Correct 1 ms 9052 KB Output is correct
4 Correct 1 ms 9052 KB Output is correct
5 Correct 2 ms 9052 KB Output is correct
6 Correct 1 ms 9052 KB Output is correct
7 Correct 1 ms 9052 KB Output is correct
8 Correct 1 ms 9052 KB Output is correct
9 Incorrect 2 ms 23644 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '322678674638'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1060 ms 155988 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1062 ms 179144 KB Time limit exceeded
2 Halted 0 ms 0 KB -