Submission #797350

#TimeUsernameProblemLanguageResultExecution timeMemory
797350makanhuliaRabbit Carrot (LMIO19_triusis)C++17
100 / 100
22 ms5952 KiB
#include <bits/stdc++.h>
#define inf INT_MAX
#define longlonginf LONG_LONG_MAX
#define mod  1000000007
#define MAXN 100005
#define ll long long
#define deb(x) cerr<<"[ "<<#x<<" = "<<x<<" ]";
#define yes() cout<<"YES\n";
#define no() cout<<"NO\n";
using namespace std;

ll n,m,k,q,x;
ll h;
ll ans = 0;
string subtask;

void solve(){
  cin>>n>>m;
  ll a[n+1];
  for(int i = 1 ; i <= n ; i++){
    cin>>a[i];
    a[i] = i*m - a[i];
  }
  vector<ll>::iterator it;
  vector<ll> v;
  for(int i = 1 ; i <= n ; i++){
    if( a[i] < 0 ) continue;
    it = upper_bound(v.begin(),v.end(),a[i]);
    if( it == v.end() ) v.push_back(a[i]);
    else *it = a[i];
  }
  cout<<n-v.size()<<"\n";
}


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int T = 1;
  //cin>>T;
  for(int i = 0 ; i < T ; i++){
    //cout<<"Case #"<<i+1<<": ";
    solve();
  }
  return 0;
}

/*
  not i but x
  logical operator
  wrong example/proof
  thoroughly
  wrong variables
  thinking it wrong
  bruh just try some test case
  capitals ;-;
  wrong data structure lol
  count memory usement
  corner case
  oversized array
  orders
  statements
  size initializer
  while con
  map -> array
  wrong digits??
  swapped variables??
  check if theres any variabled
  that got declared twice
  find some pattern
  name collision
  constraints??!
  mod !!
  resets
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...