/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
C#, OCaml, VB, Perl, Swift, Prolog, Javascript, Pascal, COBOL, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
int main(){
long n, m;
cin>>n>>m;
vector<long> x;
long a;
for(long i = 0; i<n; i++){
cin>>a;
if(((i+1)*m)-a>=0){
x.push_back(((i+1)*m)-a);
}
}
vector<long> dp = {0};
for(long i = 0; i<x.size(); i++){
long thing = (upper_bound(dp.begin(), dp.end(), x[i])-dp.begin());
if(thing==dp.size()){
dp.push_back(x[i]);
}else{
dp[thing]=x[i];
}
}
cout<<n+1-dp.size()<<endl;
return 0;
}
# | 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... |