Submission #731243

# Submission time Handle Problem Language Result Execution time Memory
731243 2023-04-27T08:09:44 Z alextodoran Catfish Farm (IOI22_fish) C++17
0 / 100
89 ms 19256 KB
/**
 _  _   __  _ _ _  _  _ _
 |a  ||t  ||o    d | |o  |
| __    _| | _ | __|  _ |
| __ |/_  | __  /__\ / _\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 100000;
const int M_MAX = 300000;

int N, M;
int X[M_MAX + 2], Y[M_MAX + 2], W[M_MAX + 2];

vector <int> onX[N_MAX + 2];

ll Fen[N_MAX + 2];
vector <int> updi;
void init () {
    while (updi.empty() == false) {
        Fen[updi.back()] = 0;
        updi.pop_back();
    }
}
void update (int pos, ll val) {
    for (int i = pos; i <= N; i += i & -i) {
        updi.push_back(i);
        Fen[i] = max(Fen[i], val);
    }
}
ll query (int pos) {
    ll val = 0;
    for (int i = pos; i >= 1; i -= i & -i) {
        val = max(val, Fen[i]);
    }
    return val;
}

ll dp[M_MAX + 2][2];
ll mxdp[N_MAX + 2];

ll 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++) {
        X[i] = _X[i - 1] + 1;
        Y[i] = _Y[i - 1] + 1;
        W[i] = _W[i - 1];
        onX[X[i]].push_back(i);
    }
    for (int x = 1; x <= N; x++) {
        if (x < N) {
            init();
            for (int i : onX[x - 1]) {
                update(Y[i], dp[i][0]);
            }
            for (int i : onX[x]) {
                dp[i][0] = query(Y[i] - 1) + W[i];
            }
        }
        if (x > 1){
            init();
            for (int i : onX[x - 1]) {
                update((N - Y[i] + 1), dp[i][1]);
            }
            for (int i : onX[x]) {
                dp[i][1] = query((N - Y[i] + 1) - 1) + W[i];
            }
        }
        if (x >= 2) {
            for (int i : onX[x]) {
                dp[i][0] = max(dp[i][0], mxdp[x - 2] + W[i]);
                dp[i][1] = max(dp[i][1], mxdp[x - 2] + W[i]);
            }
        }
        mxdp[x] = mxdp[x - 1];
        for (int i : onX[x]) {
            mxdp[x] = max({mxdp[x], dp[i][0], dp[i][1]});
        }
    }
    return mxdp[N];
}
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 13376 KB 1st lines differ - on the 1st token, expected: '40313272768926', found: '999990243'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2676 KB Output is correct
2 Incorrect 89 ms 19256 KB 1st lines differ - on the 1st token, expected: '40604614618209', found: '1999984072'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3444 KB Output is correct
2 Correct 2 ms 3412 KB Output is correct
3 Incorrect 34 ms 8656 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '16359027219341'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2596 KB Output is correct
2 Correct 2 ms 2672 KB Output is correct
3 Correct 2 ms 2672 KB Output is correct
4 Correct 3 ms 2676 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 2 ms 2772 KB Output is correct
7 Correct 2 ms 2676 KB Output is correct
8 Correct 2 ms 2676 KB Output is correct
9 Incorrect 2 ms 2644 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '87140401258'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2596 KB Output is correct
2 Correct 2 ms 2672 KB Output is correct
3 Correct 2 ms 2672 KB Output is correct
4 Correct 3 ms 2676 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 2 ms 2772 KB Output is correct
7 Correct 2 ms 2676 KB Output is correct
8 Correct 2 ms 2676 KB Output is correct
9 Incorrect 2 ms 2644 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '87140401258'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2596 KB Output is correct
2 Correct 2 ms 2672 KB Output is correct
3 Correct 2 ms 2672 KB Output is correct
4 Correct 3 ms 2676 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 2 ms 2772 KB Output is correct
7 Correct 2 ms 2676 KB Output is correct
8 Correct 2 ms 2676 KB Output is correct
9 Incorrect 2 ms 2644 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '87140401258'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3444 KB Output is correct
2 Correct 2 ms 3412 KB Output is correct
3 Incorrect 34 ms 8656 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '16359027219341'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 13376 KB 1st lines differ - on the 1st token, expected: '40313272768926', found: '999990243'
2 Halted 0 ms 0 KB -