Submission #1070108

# Submission time Handle Problem Language Result Execution time Memory
1070108 2024-08-22T11:41:46 Z beaconmc Catfish Farm (IOI22_fish) C++17
35 / 100
1000 ms 8172 KB
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include "fish.h"

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)

const ll maxn = 305;


bool fish[maxn][maxn];
ll weights[maxn][maxn];


ll dp[maxn][maxn][2];



long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
                      std::vector<int> W) {
    FOR(i,0,maxn){
        FOR(j,0,maxn){
                fish[i][j] = false;
                dp[i][j][0] = 0;
                dp[i][j][1] = 0;
        }
    }

    FOR(i,0,M){
        Y[i]++;
        fish[X[i]][Y[i]] = true;
        weights[X[i]][Y[i]] = W[i];
    }

    FOR(i,0,N){
        FOR(j,0,N+1){
            FOR(k,0,2){
                ll temp = 0;
                FOR(height,0,N+1){
                    if (k==0){
                        if (fish[i][height] && j >= height) temp -= weights[i][height];
                        if (fish[i+1][height]) temp += weights[i+1][height];
                    }else{
                        if (fish[i+1][height]) temp += weights[i+1][height];
                        if (fish[i][height] && j >= height) temp -= weights[i][height];
                        if (i > 0 && fish[i-1][height] && j < height) temp += weights[i-1][height];
                    }

                    if (height < j) dp[i+1][height][0] = max(dp[i+1][height][0], dp[i][j][k] + temp);
                    else dp[i+1][height][1] = max(dp[i+1][height][1], dp[i][j][k] + temp);
                }
            }
        }
    }
    ll ans = 0;
    FOR(i,0,N+1) FOR(j,0,N+1)FOR(k,0,2) ans = max(ans, dp[i][j][k]);
    return ans;







}
# Verdict Execution time Memory Grader output
1 Execution timed out 1053 ms 4444 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2648 KB Output is correct
2 Execution timed out 1029 ms 8172 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1057 ms 2652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2492 KB Output is correct
3 Correct 0 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2488 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 15 ms 2736 KB Output is correct
10 Correct 111 ms 2652 KB Output is correct
11 Correct 15 ms 2736 KB Output is correct
12 Correct 104 ms 2652 KB Output is correct
13 Correct 3 ms 2652 KB Output is correct
14 Correct 105 ms 2732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2492 KB Output is correct
3 Correct 0 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2488 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 15 ms 2736 KB Output is correct
10 Correct 111 ms 2652 KB Output is correct
11 Correct 15 ms 2736 KB Output is correct
12 Correct 104 ms 2652 KB Output is correct
13 Correct 3 ms 2652 KB Output is correct
14 Correct 105 ms 2732 KB Output is correct
15 Correct 106 ms 2652 KB Output is correct
16 Correct 4 ms 2652 KB Output is correct
17 Correct 141 ms 4428 KB Output is correct
18 Correct 126 ms 4520 KB Output is correct
19 Correct 117 ms 4424 KB Output is correct
20 Correct 118 ms 4512 KB Output is correct
21 Correct 117 ms 4300 KB Output is correct
22 Correct 125 ms 6236 KB Output is correct
23 Correct 123 ms 3056 KB Output is correct
24 Correct 166 ms 3896 KB Output is correct
25 Correct 106 ms 2652 KB Output is correct
26 Correct 117 ms 3028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2492 KB Output is correct
3 Correct 0 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2488 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 15 ms 2736 KB Output is correct
10 Correct 111 ms 2652 KB Output is correct
11 Correct 15 ms 2736 KB Output is correct
12 Correct 104 ms 2652 KB Output is correct
13 Correct 3 ms 2652 KB Output is correct
14 Correct 105 ms 2732 KB Output is correct
15 Correct 106 ms 2652 KB Output is correct
16 Correct 4 ms 2652 KB Output is correct
17 Correct 141 ms 4428 KB Output is correct
18 Correct 126 ms 4520 KB Output is correct
19 Correct 117 ms 4424 KB Output is correct
20 Correct 118 ms 4512 KB Output is correct
21 Correct 117 ms 4300 KB Output is correct
22 Correct 125 ms 6236 KB Output is correct
23 Correct 123 ms 3056 KB Output is correct
24 Correct 166 ms 3896 KB Output is correct
25 Correct 106 ms 2652 KB Output is correct
26 Correct 117 ms 3028 KB Output is correct
27 Runtime error 3 ms 5208 KB Execution killed with signal 11
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1057 ms 2652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1053 ms 4444 KB Time limit exceeded
2 Halted 0 ms 0 KB -