Submission #1042235

# Submission time Handle Problem Language Result Execution time Memory
1042235 2024-08-02T17:18:16 Z IdanRosen Rabbit Carrot (LMIO19_triusis) C++
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    ll n, m;
    cin >> n >> m;
    n++;

    vector<ll> arr(n);
    for (int i = 0; i < n; i++) {
        if (i == 0) arr[i] = 0;
        else {
            ll val;
            cin >> val;
            arr[i] = val - m * i;
        }
    }

    // find the length of the longest decreasing subsequence
    vector<ll> dp(n, -1);
    ll lis = 0;

    for (ll i = 0; i < n; i++) {
        ll start = 0;
        ll end = lis;
        while (start < end) {
            ll mid = start+(end-start)/2;

            if (arr[mid] >= arr[i]) start = mid + 1;
            else end = mid;
        }

        if (start != 0 || i == 0) {
            dp[start] = i;
            if (start == lis) ++lis;
        }
    }

    cout << n - lis;

}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -