Submission #1191111

#TimeUsernameProblemLanguageResultExecution timeMemory
1191111BlockOGHorses (IOI15_horses)C++20
17 / 100
1596 ms9016 KiB
#include "horses.h"
#include <bits/stdc++.h>

// mrrrrrowww :333
// this is not an ad for vivid/stasis, but you should play vivid/stasis! (it's free (steam is the official source))

#define ll long long

using namespace std;

int n, *x, *y;

int solve() {
    long long res = 0;

    vector<long long> b = {0};

    for (int i = 0; i < n; i++) {
        vector<long long> nb(b.size() * x[i]);

        for (int j = 1; j <= b.size(); j++) {
            res = max(res, (b[j - 1] + j * x[i] * y[i]) % 1000000007);
            for (int k = 0; k < j * x[i]; k++) res = max(res, nb[k] = max(nb[k], (b[j - 1] + (j * x[i] - k - 1) * y[i]) % 1000000007));
        }

        b = nb;
    }

    return res;
}

int init(int N, int X[], int Y[]) {
    n = N, x = X, y = Y;
    return solve();
}

int updateX(int pos, int val) {
    x[pos] = val;
    return solve();
}

int updateY(int pos, int val) {
    y[pos] = val;
    return solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...