Submission #735034

# Submission time Handle Problem Language Result Execution time Memory
735034 2023-05-03T11:48:40 Z MasterTaster Rabbit Carrot (LMIO19_triusis) C++14
Compilation error
0 ms 0 KB
#include <iostream>

using namespace std;

#define ll long long
#define MAXN 100010

ll n, m, a[MAXN], dp[MAXN];

int main() {

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

    int lis=0;
    for (ll i=1; i<=n; i++)
    {
        auto it=upper_bound(dp, dp+lis, m*i-a[i]);
        if (lis==0 || ((distance(dp, it))==0)) if (m*i-a[i]<0) { /*cout<<i<<" wtf"<<endl;*/ continue; }
        if (it==dp+lis)
        {
            dp[lis]=m*i-a[i];
            lis++;
            //cout<<i<<" "<<lis<<endl;
        }
        else
        {
            int j=distance(dp, it);
            dp[j]=m*i-a[i];
        }
        //for (int i=0; i<lis; i++) cout<<dp[i]<<" ";
        //cout<<endl;
    }
    cout<<n-lis;
}

Compilation message

triusis.cpp: In function 'int main()':
triusis.cpp:18:17: error: 'upper_bound' was not declared in this scope
   18 |         auto it=upper_bound(dp, dp+lis, m*i-a[i]);
      |                 ^~~~~~~~~~~