Submission #1042124

# Submission time Handle Problem Language Result Execution time Memory
1042124 2024-08-02T15:01:19 Z VMaksimoski008 Catfish Farm (IOI22_fish) C++17
35 / 100
107 ms 11708 KB
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll pref[305][305], dp[305][305][2];
 
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
    for(int i=0; i<M; i++) pref[X[i]+1][Y[i]+1] += W[i];
    for(int i=1; i<=N; i++)
        for(int j=1; j<=N; j++) pref[i][j] += pref[i][j-1];

	//nikad nema da ima pojse od 2 prazni kuli
    for(int i=1; i<N; i++) {
        for(int j=0; j<=N; j++) {
            for(int k=0; k<=N; k++) {
                if(j <= k) dp[i+1][k][1] = max(dp[i+1][k][1], dp[i][j][1] + pref[i][k] - pref[i][j]);
                if(j >= k) dp[i+1][k][0] = max(dp[i+1][k][0], max(dp[i][j][0], dp[i][j][1]) + pref[i+1][j] - pref[i+1][k]);
                if(i + 2 <= N) dp[i+2][k][0] = max(dp[i+2][k][0], max(dp[i][j][0], dp[i][j][1]) + max(pref[i+1][j], pref[i+1][k]));
                if(i + 2 <= N) dp[i+2][k][1] = max(dp[i+2][k][1], max(dp[i][j][0], dp[i][j][1]) + max(pref[i+1][j], pref[i+1][k]));
            }
        }
    }

    ll ans = 0;
    for(int i=1; i<=N; i++)
        for(int j=1; j<=N; j++) ans = max({ ans, dp[i][j][0] + pref[i+1][j], dp[i][j][1] + pref[i+1][j] });
    return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 14 ms 6740 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 35 ms 11708 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 1880 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 360 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 8 ms 1376 KB Output is correct
10 Correct 62 ms 2640 KB Output is correct
11 Correct 8 ms 1372 KB Output is correct
12 Correct 63 ms 2500 KB Output is correct
13 Correct 2 ms 860 KB Output is correct
14 Correct 63 ms 2536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 360 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 8 ms 1376 KB Output is correct
10 Correct 62 ms 2640 KB Output is correct
11 Correct 8 ms 1372 KB Output is correct
12 Correct 63 ms 2500 KB Output is correct
13 Correct 2 ms 860 KB Output is correct
14 Correct 63 ms 2536 KB Output is correct
15 Correct 62 ms 2388 KB Output is correct
16 Correct 2 ms 864 KB Output is correct
17 Correct 68 ms 4180 KB Output is correct
18 Correct 67 ms 4180 KB Output is correct
19 Correct 68 ms 4244 KB Output is correct
20 Correct 69 ms 4232 KB Output is correct
21 Correct 107 ms 4140 KB Output is correct
22 Correct 76 ms 6176 KB Output is correct
23 Correct 65 ms 2900 KB Output is correct
24 Correct 68 ms 3536 KB Output is correct
25 Correct 65 ms 2524 KB Output is correct
26 Correct 62 ms 2896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 360 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 8 ms 1376 KB Output is correct
10 Correct 62 ms 2640 KB Output is correct
11 Correct 8 ms 1372 KB Output is correct
12 Correct 63 ms 2500 KB Output is correct
13 Correct 2 ms 860 KB Output is correct
14 Correct 63 ms 2536 KB Output is correct
15 Correct 62 ms 2388 KB Output is correct
16 Correct 2 ms 864 KB Output is correct
17 Correct 68 ms 4180 KB Output is correct
18 Correct 67 ms 4180 KB Output is correct
19 Correct 68 ms 4244 KB Output is correct
20 Correct 69 ms 4232 KB Output is correct
21 Correct 107 ms 4140 KB Output is correct
22 Correct 76 ms 6176 KB Output is correct
23 Correct 65 ms 2900 KB Output is correct
24 Correct 68 ms 3536 KB Output is correct
25 Correct 65 ms 2524 KB Output is correct
26 Correct 62 ms 2896 KB Output is correct
27 Runtime error 1 ms 600 KB Execution killed with signal 11
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 1880 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 14 ms 6740 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -