Submission #771174

#TimeUsernameProblemLanguageResultExecution timeMemory
771174LextyleFinancial Report (JOI21_financial)C++17
Compilation error
0 ms0 KiB
    #include <bits/stdc++.h>
    #include <random>
    #include <chrono>
    #pragma warning(disable : 4996)
    #pragma warning(disable : 6031)
    #define USACO freopen("cowpatibility.in", "r", stdin); freopen("cowpatibility.out", "w+", stdout)
    #define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
    #define ll long long
    using namespace std;
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    ll binpow(ll a, ll x, ll m) {
        ll ans = 1, md = a % m;
        while (x != 0) {
            if (x % 2 == 1) ans = (ans * md) % m;
            md = (md * md) % m;
            x >>= 1;
        }
        return ans;
    }
    ll gcd(ll a, ll b) {
        return b == 0 ? a : gcd(b, a % b);
    }
    ll lcm(ll a, ll b) {
        return a * b / gcd(a, b);
    }

    /*
    JOJOxJJOI
    */
    int a[7000], dp[7000][7001], st[7000][7001][13], lg[7001];

    void solve() {
        int n, d;
        cin >> n >> d;
        for(int i = 0; i < n; i++) cin >> a[i];
        for(int i = 0; i < n; i++) {
            for(int j = 0; j <= n; j++) dp[i][j] = INT32_MAX;
        }
        for(int i = 0; i < n; i++) {
            dp[i][1] = a[i];
            st[i][1][0] = dp[i][1];
            for(int k = 1; i - (1 << k) + 1 >= 0; k++) {
                int i2 = i - (1 << k) + 1;
                st[i2][1][k] = min(st[i2][1][k - 1], st[i2 + (1 << (k - 1))][1][k - 1]);
            }
            for(int j = 2; j <= n; j++) {
                if (j <= i + 1) {
                    int l = max(0, i - d), r = i - 1;
                    if (min(st[l][j - 1][lg[r - l + 1]], st[r - (1 << lg[r - l + 1]) + 1][j - 1][lg[r - l + 1]]) < a[i]) dp[i][j] = a[i];
                    else dp[i][j] = min(st[l][j][lg[r - l + 1]], st[r - (1 << lg[r - l + 1]) + 1][j][lg[r - l + 1]]);
                }
                st[i][j][0] = dp[i][j];
                for(int k = 1; i - (1 << k) + 1 >= 0; k++) {
                    int i2 = i - (1 << k) + 1;
                    st[i2][j][k] = min(st[i2][j][k - 1], st[i2 + (1 << (k - 1))][j][k - 1]);
                }
            }
        }
        for(int i = n; i >= 1; i--) {
            if (dp[n - 1][i] != INT32_MAX) {
                cout << i << "\n";
                break;
            }
        }
    }

    int main() {
        //USACO;
        fastIO;
        lg[1] = 0;
        for(int i = 2, pw = 2; i <= 400; i++) {
            lg[i] = lg[i - 1];
            if (i == pw) {
                lg[i]++;
                pw *= 2;
            }
        }
        int t = 1;
        //cin >> t;
        while(t--) solve();
        return 0;
    }

Compilation message (stderr)

Main.cpp:4: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
    4 |     #pragma warning(disable : 4996)
      | 
Main.cpp:5: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
    5 |     #pragma warning(disable : 6031)
      | 
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status