Submission #635145

#TimeUsernameProblemLanguageResultExecution timeMemory
635145VasLemmyRabbit Carrot (LMIO19_triusis)C++17
100 / 100
34 ms6924 KiB
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define fi first
#define se second
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")*/
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ldb = long double;
const int N = 1e4;
const int maxN = 5e5 + 15;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll infty = 1e17 + 7;
const int base = 4e5;
const int Block_size = 350;

void InputFile()
{
    freopen("cowjog.in","r",stdin);
    freopen("cowjog.out","w",stdout);
    //freopen("test.out","r",stdin);
}

void FastInput()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int n,M;
int a[maxN];
ll e[maxN];
ll dp[maxN];

void Read()
{
    cin >> n >> M;
    for(int i = 1;i <= n;i++)
    {
        cin >> a[i];
        a[i] -= i * M;
    }
    fill(e + 1,e + n + 1,infty);
    ll res = 0;
    for(int i = n;i >= 1;i--)
    {
        dp[i] = upper_bound(e + 1,e + n + 1,a[i]) - e;
        e[dp[i]] = a[i];
        if(a[i] <= 0) res = max(res,dp[i]);
    }
    cout << n - res;
}

void Solve()
{

}

void Debug()
{

}


int32_t main()
{
    FastInput();
    //InputFile();
    //int sub_type;
    //cin >> sub_type;
    //Sieve();
    //Prepare();
    int test;
    //cin >> test;
    test = 1;
    while(test--)
    {
        Read();
        Solve();
        //Debug();
    }
}

Compilation message (stderr)

triusis.cpp: In function 'void InputFile()':
triusis.cpp:25:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     freopen("cowjog.in","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
triusis.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen("cowjog.out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...