#include <bits/stdc++.h>
using namespace std;
#define start cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define endl '\n'
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fflush(stdout); cout.flush();
/*********************************/
/*********************************/
int a[200005], b[200005];
int main(){
start
int n, m; cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>a[i];
b[i]=(m*i)-a[i];
}
vector<int>v;
v.push_back(0);
for(int i=1;i<=n;i++){
int x=b[i];
if(x<0) continue;
int l=0, r=v.size()-1;
int idx=-1;
while(l<=r){
int mid=(l+r)/2;
if(x<=v[mid]){
r=mid-1;
idx=mid;
}
else l=mid+1;
}
if(idx!=-1) v[idx]=x;
else v.push_back(x);
}
int komp=v.size();
cout<<n-komp<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |