This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int N = 2e5 + 5;
int n , a[N] , M;
vector <int> vec;
int main(){
cin >> n >> M;
for(int i = 1,x; i <= n; i++){
a[i] = 2e9;
cin >> x;
if(x <= i * M)
vec.push_back(i*M - x);
}
int mx = 0;
for(int x : vec){
int j = upper_bound(a , a + n + 1 , x) - a;
a[j] = x;
if(j > mx)mx = j;
}
cout << n - mx;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |