Submission #1169460

#TimeUsernameProblemLanguageResultExecution timeMemory
1169460ethanspoonRabbit Carrot (LMIO19_triusis)C++20
100 / 100
52 ms5048 KiB
/******************************************************************************

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...