Submission #944944

# Submission time Handle Problem Language Result Execution time Memory
944944 2024-03-13T08:39:31 Z imann Rabbit Carrot (LMIO19_triusis) C++17
0 / 100
1 ms 2652 KB
#include <iostream>
#include <array>
#include <algorithm>
#include <limits>

using ll = long long;

const int MAX_N = 2*1000*100 + 3;

std::array<ll, MAX_N> As, dp;

int solve(int n) {
  std::reverse(As.begin(), As.begin() + n);

  dp.fill(std::numeric_limits<ll>::max());
  for (int i = 0; i < n; ++i) {
    if (As[i] < 0) {
      int j = std::upper_bound(dp.begin(), dp.begin() + n, As[i]) - dp.begin();
      dp[j] = As[i];
    }
  }

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (dp[i] != std::numeric_limits<ll>::max())
      ans = i + 1;
  }
  return ans;
}

int main() {
  int n, m; std::cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    std::cin >> As[i];
    As[i] -= (i + 1) * m;
  }
  std::cout << n - solve(n) << std::endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -