Submission #470402

#TimeUsernameProblemLanguageResultExecution timeMemory
470402Yazan_AlattarRabbit Carrot (LMIO19_triusis)C++14
100 / 100
35 ms2564 KiB
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <cmath>
#include <numeric>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
const int M = 200007;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const double pi = acos(-1);

vector <ll> v;
ll n, m;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; ++i){
        ll x;
        cin >> x;
        x = m * i - x;
        if(x < 0) continue;
        auto it = upper_bound(v.begin(), v.end(), x);
        if(it == v.end()) v.pb(x);
        else *it = x;
    }
    cout << n - v.size() << endl;
    return 0;
}
// Don't forget special cases. (n = 1?)
// Look for the constraints. (Runtime array? overflow?)
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...