Submission #549906

# Submission time Handle Problem Language Result Execution time Memory
549906 2022-04-16T19:49:56 Z Alexandruabcde Rabbit Carrot (LMIO19_triusis) C++14
0 / 100
1 ms 340 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
constexpr int NMAX = 2e5 + 5;

int N, M;
LL A[NMAX];

void Read () {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> N >> M;

    for (int i = 1; i <= N; ++ i ) {
        cin >> A[i];

        A[i] -= (1LL * i * M);
    }
}

int vf;
LL Best[NMAX];

int CautBinar (LL value) {
    int st = 1, dr = vf;
    int ans = 0;

    while (st <= dr) {
        int mij = (st + dr) / 2;

        if (Best[mij] <= value) {
            st = mij + 1;
            ans = mij;
        }
        else dr = mij - 1;
    }

    return ans;
}

void Solve () {
    for (int i = 0; i <= N; ++ i ) {
        int pos = CautBinar(A[i]) + 1;

        if (pos > vf) {
            ++ vf;
            Best[vf] = A[i];
        }

        Best[pos] = min(Best[pos], A[i]);
    }

    cout << vf - 1 << '\n';
}

int main () {
    Read();
    Solve();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -