Submission #839361

# Submission time Handle Problem Language Result Execution time Memory
839361 2023-08-29T20:05:23 Z Trunkty Catfish Farm (IOI22_fish) C++17
0 / 100
843 ms 154416 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=1;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][k]+prearr[i+1][j]);
                }
                else{
                    dp2[i][j] = max(dp2[i][j],max(dp[i-1][k],dp2[i-1][k])-prearr[i][j]+prearr[i+1][j]);
                }
            }
        }
    }
    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 811 ms 150348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Runtime error 802 ms 154416 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 843 ms 143852 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 352 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Incorrect 7 ms 3188 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 1 ms 352 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Incorrect 7 ms 3188 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 1 ms 352 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Incorrect 7 ms 3188 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 843 ms 143852 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 811 ms 150348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -