# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1270369 | toastercultist | Rabbit Carrot (LMIO19_triusis) | C++20 | 1 ms | 332 KiB |
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#ifndef LOCAL
void fileh(string file) {
ios_base::sync_with_stdio(false); cin.tie(NULL);
if (file == "") return;
freopen((file + ".in").c_str(), "r", stdin);
freopen((file + ".out").c_str(), "w", stdout);
}
#define log(x)
#define debug(x)
#define debugv(v)
#else
void fileh(string file) {}
#define log(x) cerr << x << "\n";
#define debug(x) cerr << #x << " = " << (x) << "\n"
#define debugv(v) cerr << #v << " = "; for(auto x : v) cerr << x << " "; cerr << "\n"
#endif
/*--*/
/*--*/
signed main() { fileh("");
ll n, m; cin >> n >> m;
vector<ll> a (n);
for (ll i = 0; i < n; i ++) cin >> a[i];
for (ll i = 0; i < n; i ++) {
a[i] -= (i + 1) * m;
}
debugv(a);
vector<ll> dp; dp.reserve(n); // longest non-increasing sequence
for (ll i = 0; i < n; i ++) {
if (a[i] > 0) continue;
if (dp.size() <= 0 || dp.back() >= a[i]) {
dp.push_back(a[i]);
} else {
auto p = lower_bound(dp.rbegin(), dp.rend(), a[i], greater<ll> ());
auto ap = p.base();
log("aa");
log(a[i]);
if (ap != dp.end()) {
log(*ap);
*ap = a[i];
} else {
log("no\n");
}
}
}
ll ans = n - dp.size();
cout << ans << "\n";
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... |