제출 #977424

#제출 시각아이디문제언어결과실행 시간메모리
977424mika_uwuRabbit Carrot (LMIO19_triusis)C++17
0 / 100
1 ms600 KiB
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define popb pop_back
#define all(A) A.begin(),A.end()
#define rall(A) A.rbegin(),A.rend()
#define dic unordered_map
#define bpc __builtin_popcountll//numero de bits para long long
#define bclz __builtin_clzll//leading zeros para ll
#define max_bit(A) 31-__builtin_clz(A)

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(12) << fixed;
    int n,m;
    cin>>n>>m;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i],a[i]=(i+1)*m-a[i];
    //for(int i=0;i<n;i++) cout<<a[i]<<" ";
    //cout<<"\n";
    vector<int> lis;
    for(int i=0;i<n;i++){
        if(a[i]>=0){
            if(lis.size()==0 || lis.back()<=a[i]) lis.pb(a[i]);
            else{
                int pos=lower_bound(all(lis),a[i])-lis.begin();
                lis[pos]=a[i];
            }
        }
    }
    cout<<n-lis.size()<<"\n";
    return 0;
    // you should actually read the stuff at the bottom
}

/* stuff you should look for
    * int overflow, array bounds
    * bitwise and boolean operations
    * special cases (n=1?)
    * do smth instead of nothing and stay organized
    * WRITE STUFF DOWN
    * DON'T GET STUCK ON ONE APPROACH
*/

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...