Submission #1022918

# Submission time Handle Problem Language Result Execution time Memory
1022918 2024-07-14T07:34:33 Z vjudge1 Catfish Farm (IOI22_fish) C++17
35 / 100
1000 ms 205160 KB
#include "fish.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define ff first
#define ss second

const int MAXN = 300100;
int n, w[MAXN], m;
pii a[MAXN];

namespace A{
    ll solve(){
        ll ans = 0;
        for(int i=1; i<=m; i++){
            ans += w[i];
        }
        return ans;
    }
}

namespace B{
    ll d[3001][3001];
    ll dp[3001][3001];
    ll pref[3001][3001];
    ll ddp[3001][3001];
    ll solve(){
        int mxh = 0;
        for(int i=1; i<=m; i++){
            d[a[i].ff][a[i].ss] += w[i];
            mxh = max(mxh, a[i].ss);
        }
        for(int i=1; i<=n; i++){
            dp[0][i] = -1e18;
            ddp[0][i] = -1e18;
        }
        dp[0][0] = 0;
        ddp[0][0] = 0;
        for(int i=1; i<=n; i++){
            for(int j=1; j<=n; j++){
                pref[i][j] = pref[i][j - 1] + d[i][j];
            }
            for(int j=0; j<=mxh; j++){
                ddp[i][j] = 0;
                dp[i][j] = 0;
                for(int k=0; k<=j; k++){
                    ddp[i][j] = max(ddp[i][j], ddp[i-1][k] + pref[i-1][j]-pref[i-1][k]);
                }
                for(int k=0; k<=mxh; k++){
                    ddp[i][j] = max(ddp[i][j], dp[i-1][k]);
                }
                dp[i][j] = ddp[i][j];
                for(int k=j; k<=mxh; k++){
                    dp[i][j] = max(dp[i][j], dp[i-1][k] + pref[i][k] - pref[i][j]);
                }
                for(int k=0; k<=j; k++){
                    dp[i][j] = max(dp[i][j], ddp[i-1][k] + pref[i-1][j] - pref[i-1][k]);
                }
                if(i < 2) continue;
                for(int k=0; k<=mxh; k++){
                    dp[i][j] = max(dp[i][j], dp[i-2][k] + pref[i-1][max(k, j)]);
                }
            }
        }
        //for(int i=1; i<=n; i++){
        //    for(int j=0; j<=n; j++){
        //        cout<<dp[i][j]<<' ';
        //    }
        //    cout<<'\n';
        //}
        ll ans = 0;
        for(int i=0; i<=n; i++) ans = max(ans, dp[n][i]);
        return ans;
    }
}

long long max_weights(int N, int M, vector<int> X, vector<int> Y,
                      vector<int> W) {
    n = N;
    m = M;
    for(int i=1; i<=m; i++){
        a[i] = {X[i-1]+1, Y[i-1]+1};
    }
    for(int i=1; i<=m; i++){
        w[i] = W[i-1];
    }
    int ok1 = 1;
    for(int i=1; i<=m; i++){
        ok1 &= (a[i].ff % 2 == 0);
    }
    if(ok1) return A::solve();
    return B::solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 7812 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Execution timed out 1083 ms 9012 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 421 ms 205160 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2408 KB Output is correct
2 Correct 1 ms 616 KB Output is correct
3 Correct 0 ms 360 KB Output is correct
4 Correct 0 ms 360 KB Output is correct
5 Correct 0 ms 360 KB Output is correct
6 Correct 1 ms 360 KB Output is correct
7 Correct 0 ms 360 KB Output is correct
8 Correct 0 ms 360 KB Output is correct
9 Correct 1 ms 2920 KB Output is correct
10 Correct 3 ms 5992 KB Output is correct
11 Correct 2 ms 2920 KB Output is correct
12 Correct 3 ms 5992 KB Output is correct
13 Correct 1 ms 1628 KB Output is correct
14 Correct 3 ms 6060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2408 KB Output is correct
2 Correct 1 ms 616 KB Output is correct
3 Correct 0 ms 360 KB Output is correct
4 Correct 0 ms 360 KB Output is correct
5 Correct 0 ms 360 KB Output is correct
6 Correct 1 ms 360 KB Output is correct
7 Correct 0 ms 360 KB Output is correct
8 Correct 0 ms 360 KB Output is correct
9 Correct 1 ms 2920 KB Output is correct
10 Correct 3 ms 5992 KB Output is correct
11 Correct 2 ms 2920 KB Output is correct
12 Correct 3 ms 5992 KB Output is correct
13 Correct 1 ms 1628 KB Output is correct
14 Correct 3 ms 6060 KB Output is correct
15 Correct 75 ms 7252 KB Output is correct
16 Correct 3 ms 1624 KB Output is correct
17 Correct 83 ms 9024 KB Output is correct
18 Correct 83 ms 10344 KB Output is correct
19 Correct 83 ms 11088 KB Output is correct
20 Correct 85 ms 11092 KB Output is correct
21 Correct 32 ms 10324 KB Output is correct
22 Correct 105 ms 12880 KB Output is correct
23 Correct 91 ms 10320 KB Output is correct
24 Correct 81 ms 11088 KB Output is correct
25 Correct 3 ms 8024 KB Output is correct
26 Correct 82 ms 7936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2408 KB Output is correct
2 Correct 1 ms 616 KB Output is correct
3 Correct 0 ms 360 KB Output is correct
4 Correct 0 ms 360 KB Output is correct
5 Correct 0 ms 360 KB Output is correct
6 Correct 1 ms 360 KB Output is correct
7 Correct 0 ms 360 KB Output is correct
8 Correct 0 ms 360 KB Output is correct
9 Correct 1 ms 2920 KB Output is correct
10 Correct 3 ms 5992 KB Output is correct
11 Correct 2 ms 2920 KB Output is correct
12 Correct 3 ms 5992 KB Output is correct
13 Correct 1 ms 1628 KB Output is correct
14 Correct 3 ms 6060 KB Output is correct
15 Correct 75 ms 7252 KB Output is correct
16 Correct 3 ms 1624 KB Output is correct
17 Correct 83 ms 9024 KB Output is correct
18 Correct 83 ms 10344 KB Output is correct
19 Correct 83 ms 11088 KB Output is correct
20 Correct 85 ms 11092 KB Output is correct
21 Correct 32 ms 10324 KB Output is correct
22 Correct 105 ms 12880 KB Output is correct
23 Correct 91 ms 10320 KB Output is correct
24 Correct 81 ms 11088 KB Output is correct
25 Correct 3 ms 8024 KB Output is correct
26 Correct 82 ms 7936 KB Output is correct
27 Execution timed out 1083 ms 18024 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 421 ms 205160 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 7812 KB Time limit exceeded
2 Halted 0 ms 0 KB -