#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 |
- |