# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
635145 | VasLemmy | Rabbit Carrot (LMIO19_triusis) | C++17 | 34 ms | 6924 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |