Submission #1327328

#TimeUsernameProblemLanguageResultExecution timeMemory
1327328hoangtien69Rabbit Carrot (LMIO19_triusis)C++20
100 / 100
19 ms4180 KiB
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 2e5 + 5;

int n, d;
int a[MAXN];
vector<int> peal;

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> d;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }

    for (int i = 1; i <= n; i++)
    {
        if (i * d >= a[i])
        {
           int x = i * d - a[i];
           int pos = upper_bound(peal.begin(), peal.end(), x) - peal.begin();
           if (pos == peal.size())
           {
               peal.push_back(x);
           }
           else
           {
                peal[pos] = x;
           }
        }
    }
    cout << n - peal.size();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...