#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int mxN = (int) 2e5, mxM = 5000;
int n, m;
ll d[mxN + 1], dp[mxN + 1];
int lnds() {
dp[0] = LLONG_MIN;
fill(dp + 1, dp + 1 + n, LLONG_MAX);
for(int i = 1; i <= n; i++) {
int l = upper_bound(dp, dp + 1 + n, d[i]) - dp;
dp[l] = d[i];
}
for(int l = n; l >= 1; l--) {
if(dp[l] != LLONG_MAX) return l;
}
return 1;
}
int main(){
cin >> n >> m;
for(int i = 1; i <= n; i++) {
int temp; cin >> temp;
d[i] = 1ll * m * i - temp;
}
cout << n - lnds();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |