# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1156715 | eudhsyf | Rabbit Carrot (LMIO19_triusis) | C++20 | 18 ms | 4936 KiB |
/*
Author :
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pii pair<int, int>
#define pb push_back
#define eb emplace_back
#define task "file"
const int nmax = 1e6 + 5;
int n, dp[nmax], m, a[nmax];
signed main()
{
if (fopen(task ".inp", "r"))
{
freopen(task ".inp", "r", stdin);
freopen(task ".out", "w", stdout);
}
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++)
{
cin >> a[i];
a[i] = i * m - a[i];
}
memset(dp, 0x3f, sizeof(dp));
dp[0] = 0;
int d = 0;
for (int i = 1; i <= n; i++)
{
if (a[i] >= 0)
{
int l = 1, r = d, id = 0;
while (l <= r)
{
int mid = l + r >> 1;
if (dp[mid] <= a[i])
{
id = mid,
l = mid + 1;
}
else
r = mid - 1;
}
if (id == d)
d++;
dp[id + 1] = a[i];
}
}
cout << n - d;
return 0;
}
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... |