#include <bits/stdc++.h>
using namespace std;
#define file "file"
const long long N=2e5+5;
long long n,M,i,j,res,b[N],f[N];
int main()
{
//freopen(file".inp", "r", stdin);
//freopen(file".out", "w", stdout);
ios_base::sync_with_stdio(); cin.tie();
cin>>n>>M;
for (i=1;i<=n;i++)
{
cin>>j; b[i]=M*i-j;
}
f[0]=INT_MIN;
for (i=1;i<=n;i++)
{
if (b[i]>=f[res]) {res++; f[res]=b[i]; continue;}
j=upper_bound(f+1, f+res+1, b[i]) - f;
f[j]=b[i];
}
cout<<n-res;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
- |