제출 #977979

#제출 시각아이디문제언어결과실행 시간메모리
977979mohamedsiuRabbit Carrot (LMIO19_triusis)C++14
100 / 100
21 ms6472 KiB
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
using ll = long long;
using ld = long double;
const int maxn = 3e5 + 5;
const int maxN = 1e5;
const int mod = 1e9 + 7;
const ll inf = 1e18;
const int tt = 5e3 + 5;
const int base = 31;
const int lim = 100;
const int BLOCK_SIZE = 340;
const int TWO_MOD_INV = 500000004;
int dx[] = {0,-1,0,1,-1,1,-1,1};
int dy[] = {-1,0,1,0,-1,1,1,-1};

int n,m;
int a[maxn];
int d[maxn];

void Read()
{
    cin >> n >> m;
    for(int i = 1;i <= n;i++)
    {
        cin >> a[i];
        a[i] = i*m - a[i];
    }
    int sz = 0;
    int res = 0;
    for(int i = 1;i <= n;i++)
    {
        if(a[i] >= 0)
        {
            int k = upper_bound(d + 1,d + sz + 1,a[i]) - d;
            sz = max(sz,k);
            res = max(res,sz);
            d[k] = a[i];
        }
    }
    cout << n - res;
}

void Solve()
{
}

void Debug()
{
}


int32_t main()
{
//    freopen("test.in","r",stdin);
//    freopen("test.out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int tt;
    tt = 1;
//    Prepare();
//    cin >> tt;
    for(int i = 1; i <= tt; i++)
    {
        Read();
        Solve();
        Debug();
    }
}
/*
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...