Submission #958647

# Submission time Handle Problem Language Result Execution time Memory
958647 2024-04-06T09:42:13 Z Bodisha Rabbit Carrot (LMIO19_triusis) C++17
0 / 100
0 ms 344 KB
#include <bits/stdc++.h>
#define MAX_N 200005
#define MAX_A 1000000005

using namespace std;

int n, m;
int poles[MAX_N];
int dp[MAX_N];

int lds() {
    dp[0] = MAX_A;
    for(int i = 1; i <= n + 1; i++) {
        dp[i] = -1;
    }
    for(int i = 0; i <= n; i++) {
        int l = 0, r = n + 1;
        int ans;
        while(l <= r) {
            int mid = l + (r - l) / 2;
            if(dp[mid] <= poles[i] && poles[i] - dp[mid] < m) {
                ans = mid;
                r = mid - 1;
            } else {
                l = mid + 1;
            }
        }
        dp[ans] = poles[i];
    }
    for(int i = 1; i <= n + 1; i++) {
        if(poles[i] == -1) {
            return i - 1;
        }
    }
    return n + 1;
}

int main() {
    cin >> n >> m;
    poles[0] = 0;
    for(int i = 1; i <= n; i++) {
        cin >> poles[i];
    }
    cout << lds() - 1;
    return 0;
}

Compilation message

triusis.cpp: In function 'int lds()':
triusis.cpp:28:17: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   28 |         dp[ans] = poles[i];
      |         ~~~~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -