Submission #839366

# Submission time Handle Problem Language Result Execution time Memory
839366 2023-08-29T20:58:52 Z Trunkty Catfish Farm (IOI22_fish) C++17
0 / 100
822 ms 153104 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define int ll

#include "fish.h"

ll arr[3005][3005],prearr[3005][3005];
ll dp[3005][3005],dp2[3005][3005]; // dp2 if adjacent AND lower

ll max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w){
    for(int i=0;i<m;i++){
        arr[x[i]+1][y[i]+1] = w[i];
    }
    for(int i=1;i<=n;i++){
        for(int j=0;j<=n;j++){
            prearr[i][j] = prearr[i][j-1]+arr[i][j];
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=0;j<=n;j++){
            // if first port
            dp[i][j] = prearr[i-1][j]+prearr[i+1][j];
            if(i-1<=0){
                continue;
            }
            for(int k=0;k<=n;k++){
                // build port at x=i, height = j, connects to port at x=i-1, height = k
                if(j>k){
                    dp[i][j] = max(dp[i][j],dp[i-1][k]-prearr[i][k]+prearr[i+1][j]+prearr[i-1][j]-prearr[i-1][k]);
                }
                else if(j==k){
                    dp[i][j] = max(dp[i][j],max(dp[i-1][k],dp2[i-1][k])-prearr[i][j]+prearr[i+1][j]);
                }
                else if(j<k){
                    dp2[i][j] = max(dp2[i][j],max(dp[i-1][k],dp2[i-1][k])-prearr[i][j]+prearr[i+1][j]);
                }
            }
            if(i-2<=0){
                continue;
            }
            for(int k=0;k<=n;k++){
                // build port at x=i, height = j, connects to port at x=i-2, height = k
                dp[i][j] = max(dp[i][j],dp[i-2][k]+prearr[i-1][j]+prearr[i+1][j]-2LL*prearr[i-1][min(j,k)]);
            }
        }
    }
    ll ans=0;
    for(int i=0;i<=n;i++){
        ans = max(ans,max(dp[n][i],dp2[n][i]));
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 768 ms 149124 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Runtime error 789 ms 153104 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 822 ms 143820 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Incorrect 12 ms 3284 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '214837477243'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Incorrect 12 ms 3284 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '214837477243'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Incorrect 12 ms 3284 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '214837477243'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 822 ms 143820 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 768 ms 149124 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -